๐Ÿ‘ฉ‍๐Ÿ’ปProgramming/Coding Test

[C#] [BOJ#13063] Lobby

taesooya 2022. 8. 14.

https://www.acmicpc.net/problem/13063

 

13063๋ฒˆ: Lobby

There are multiple test cases in the input. Each test case appears in one line containing three space-separated integers n, m and k which respectively are the total number of members, the number of members in the Conservative Party and the number of member

www.acmicpc.net

My Solution


using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] n = Array.ConvertAll<string, int>(Console.ReadLine().Split(), int
                    .Parse);
                if (n[0] == 0)
                    break;
                int goal = (n[0] % 2 == 0 ? (n[0] / 2) + 1 : (n[0] + 1) / 2);
                int rest = n[0] - (n[1] + n[2]);
                int lobby = goal - n[1];
                if (lobby < 0) lobby = 0;
                Console.WriteLine(goal > n[1] + rest ? -1 : lobby);
            }
        }
    }
}

๋Œ“๊ธ€