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);
}
}
}
}
'๐ฉโ๐ปProgramming > Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [C#][programmers] ๋ฐฐ์ด ์์์ ๊ธธ์ด (0) | 2022.11.10 |
|---|---|
| [C#][programmers] ๋ฌธ์์ด ๋ค์ง๊ธฐ (0) | 2022.11.10 |
| [C#] [BOJ#2445] ์ง๋ฅํ ๊ธฐ์ฐจ (0) | 2022.08.14 |
| [C#] [BOJ#5073] ์ผ๊ฐํ๊ณผ ์ธ ๋ณ (0) | 2022.08.14 |
| [C#] [BOJ#2775] ๋ถ๋ ํ์ฅ์ด ๋ ํ ์ผ (0) | 2022.08.14 |
๋๊ธ