GIRLSNBS - Girls and Boys

no tags 

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-
ments.

Input

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.

Output

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.

Example

Input: 
10 10
5 1
0 1000
-1 -1
Output:
1
3
1000

hide comments
anshul0311: 2017-09-11 21:29:29

Why minimum gender regularity is not 2 in second test case G G B G G G , min two consecutive girls will be there

paramvir: 2017-08-29 19:19:05

three lines of code . . took a little time but don't give up :)

madhur4127: 2017-08-20 10:06:20

my first problem to get AC in first sub, yeah!

himanshu_12345: 2017-06-15 18:32:31

can anyone tell why i am getting wrong answer this is the link
http://www.spoj.com/submit/GIRLSNBS/id=19617732

ramesh_961: 2017-05-30 08:00:05

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!!
And Thanks To "yashrocks22" for his comment!!

Last edit: 2017-05-30 08:00:54
yashrocks22: 2017-05-29 23:29:48

Simple pigeonhole principle!!

preetham_7399: 2017-04-23 09:05:53

AC in one go .., Just paper work needed ..,

dileep9259: 2017-03-22 20:22:44

Nothing much....Just a little thinking... be practical... :P

shiv pratap singh: 2017-03-17 16:30:14

very simple problem just we have to do division

Last edit: 2017-03-17 16:30:32
pushkars: 2017-03-09 19:12:50

Test Case (0,0) cost me two WA's...nice one


Added by:Pablo Ariel Heiber
Date:2010-09-27
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC VB.NET
Resource:FCEyN UBA ICPC Selection 2010