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.
pigeonhole principle !!
AC in one go very simple math needed
AC in one go!!
AC in one go!!!!
Consider case of both boys and girls to be zero. Gave me a WA once :(
Why minimum gender regularity is not 2 in second test case G G B G G G , min two consecutive girls will be there
three lines of code . . took a little time but don't give up :)
my first problem to get AC in first sub, yeah!
can anyone tell why i am getting wrong answer this is the link
Hey I learnt usuage of discrete maths here!! I.e, using a PIGEON HOLE principle!! Nice One!! Read it, just think a little,and u get it using Pigeon Hole Principle!!