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


10 10
5 1
0 1000
-1 -1

hide comments
Daljeet Singh: 2015-03-28 09:04:43

more test cases:-
10 4
11 4
5 20
10 20


pyratezzz: 2015-03-26 20:59:59

AC in first go :)

ruler: 2015-03-08 11:08:49

accepted on the first go :)

kunal todi: 2015-03-01 12:46:04

can anyone give me more test cases

Amber: 2015-02-21 12:32:40

Plz give me more testcases.

Vikki Kumar: 2015-02-19 12:13:56

Don't miss the Case 0 0

Nitesh Dodeja: 2015-01-19 21:25:30

Also consider the case 0 0

humblefool_2: 2014-12-02 23:36:09

my 50th! :-)

shankar: 2014-09-19 14:56:53

Too easy should be a practise problem

(Tjandra Satria Gunawan)(曾毅昆): 2013-08-16 05:52:28

again, first solver in AWK language. My AWK code length is only 55B ;-)

Added by:Pablo Ariel Heiber
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