Editorial for COCI '10 Contest 1 #1 Timsko
Submitting an official solution before solving the problem yourself is a bannable offence.
Observe that a team can be formed if three conditions are satisfied: the number of girls is at least
while (M ≥ 2 and N ≥ 1 and M+N ≥ K+3) do
{
result := result+1; (increment the number of formed teams)
M := M-2; (decrease the number of girls)
N := N-1; (decrease the number of boys)
}
Alternative solution
If there are at least twice as many girls as there are boys, we can say that they form a surplus regarding team formation, otherwise the boys form a surplus. Thus, we can repeat
Comments