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.
The problem statement is highly confusing and poor test cases :(
it's an easy one,you just need to see what are they asking from you.And you should take care of case b=0 g=0.
Direct formula.. Don't need to check for case "0 0". It is automatically cover in that formula.. :)
can anyone explain 2nd test case
got one WA coz not included the G=0 B=0 case...take care of this ...otherwise very easy problem...my 25th..;)
Let g be the number of girls and b be the number of boys and let b>g. Now, if * represents the girls and let their arrangement be like :
@uptoyou .. think of a straight line in which you have to adjust boys and girls. You want to adjust them uniformly so that no gender appears to be more in number than the other one. I'll explain the test cases to you. for 5 G and 1 B, 1 boy will sit in between the girls .. therefore 2 girls will be on one side of the boy and 3 on one side. in case of 10 G nd 10 B, each B and G can sit alternatively therefore 1 is the answer. Hope you get it :)
AC in one go !! Just think for a little time and you should get the logic. It's very simple.
The problem's test cases are bad....they make you think of a total different thing....take your time while you're reading yhis problem..." the same gender (all girls OR all boys) that appear consecutively."