GIRLSNBS - Girls and Boys
There are G girl students and B boy students in a class that is about to graduate. You need to arrange them in a single row for the graduation. To give a better impression of diversity, you want to avoid having too many girls or too many boys seating consecutively. You decided to arrange the students in order to minimize the gender regularity. The gender regularity of an arrangement is the maximum number of students of the same gender (all girls or all boys) that appear consecutively. Given G and B, calculate the minimum gender regularity among all possible arrangements.
Each test case is described using a single line. The line contains two integers G and B representing the number of girls and boys in the class, respectively (0 ≤ G, B ≤ 1000). The end of input is indicated with a line containing the number −1 twice.
For each test case, output a single line with a single integer representing the minimum gender regularity that an arrangement of G girls and B boys can have.
After dozens of tentatives, my Python 3 code got AC in 0.00s (use ceil division). Nice problem. Input has a trailing line.
The comments section should be in another page, people just post their solutions instead of hints.
@zacle please make sure that you don't post answers in comments.
AC in one go...if girls>boys the output is (girsls / (boys+1) ) or ((girls/(boys+1))+1) do the same if boys>girls by replacing boys by girls and don't forget to check the case where both are 0 or the same number..if they are 0 print 0 else 1..Hope that can help
for 5 1 the solution that i thought was g g g g b g but the solution is g g g b g g. hope that helps other.25th atlast :|
can you please give one more test case of unequal numbers of G and B, to understand this problem better.
Easy!! AC in first go :)
Am i a slow thinker or everybody took almost 40 minutes to solve this?????Please let me know
AC in one go...simple direct formula...