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 arrange-
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.
Nothing much....Just a little thinking... be practical... :P
shiv pratap singh:
very simple problem just we have to do divisionLast edit: 2017-03-17 16:30:32
Test Case (0,0) cost me two WA's...nice one
It looked tough initially to me.Thought that required combinatrics . Finally turned out to be an adhoc. Nice logic a bit of brainstorming required.
Beware of cases where a and b is 0
beware of the permutations, nice logic :)
@baadshah_ i passed all your test case but still I got WA. :-(
Easy one. Read it second time. Got in less than 5 minutes. AC in a go.
good question::--> my 50th;;
i loved this problem !