emli's blog

By emli, 11 years ago, In English
http://www.spoj.pl/problems/GIRLSNBS/

Do you have any idea? it seems very simple but ....
 
 
 
 
  • Vote: I like it
  • -5
  • Vote: I do not like it

11 years ago, # |
  Vote: I like it 0 Vote: I do not like it
The concept is very simple...
Assuming that there no. of boys (b) < no. of girls (g), then, we have b + 1 places where we can fills groups of girls. To minimize the number of girls in a line, we shall try to distribute them equally, i.e., g / (b + 1) girls everywhere.

If g % (b + 1) != 0, then we shall distribute g % (b + 1) girls in those many places and the answer then becomes g / (b + 1) + 1.

Trivial cases, g = b, answer is 1.
g or b = 0, answer is b or g respectively.