Given the seat counts of two parties, find how many independents must vote yes for a strict majority.
Easy2MathImplementationNo attempts yetTime limit2sMemory limit512 MBYou are a member of the "Conservative Party" in parliament. One more party, the "Reformist Party", also holds seats, and every other member is an independent who belongs to neither party. When a bill goes to a vote, each member of the two parties votes the way that member's own party decided. An independent decides how to vote after the lobbying that surrounds every vote. Parliament decides by majority rule. A bill passes only when more than half of all members vote for it.
A bill is about to reach the floor, and you know that the Reformist Party is against it. You and your party-mates want to lobby the independents so that enough of them vote for the bill and it passes. Find the minimum number of independents who have to vote the way you want for the bill to pass.
The input holds several test cases. Each test case is one line with three space separated integers n, m and k: the total number of members, the number of members of the Conservative Party, and the number of members of the Reformist Party (1≤n,m,k≤1000, m+k≤n). The last line of the input is 0 0 0 and is not processed.
For each test case, print on its own line the minimum number of independents who have to vote the way you want so that the bill passes. Print -1 if no set of independents can pass the bill.