HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


50252 - Birthday

Guest
• Discussion of problem (1)

Section problems

• 50948 - Translate Score into Grade
• 51104 - Steel
• 51113 - The Menu
• 51112 - Even Numbers
• 51105 - Currency System
• 51103 - Is it a triangle?
• 51114 - The traveling vehicle
• 50251 - Symmetric matrix
• 50252 - Birthday
• 50239 - Eating cheese
• 50244 - Chessboard Pattern
• 50245 - Santa Gifts
• 50256 - Sequence
• 50257 - Galls village
• 50280 - Division
• 50266 - Kovrov
• 50254 - Lawyers Council

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Beta

For his birthday came N people. At some point the birthday boy decided it was time to arrange a game. He found that i -th person agree to join a game if it has already taken part at least A [ i ] and not more than B [ i ] people. Once come into play, none of it comes out. Need to figure out, can Is birthday establish a sequence of entry into the game, with the result that all those present will be its members. (Birthday boy himself the game does not participate.)

Input
First, we introduce the number of guests N (1 ≤ N ≤ 100). Then injected N pairs of numbers A [ i ] and B [ i ] (All these numbers in the range from 0 to N -1).
Output
If you can determine the sequence of entry reviews a game so that eventually all become parties to it, output 1. If all involve the game fails, output 0.

input 1 Input 2 Input 3
5
4 4
0 3
1 4
1 3
2 2
3
1 1
1 1
1 1
1
0 0
Output 1 Output 2 Output 3
1
0
1

Для отправки решений необходимо выполнить вход.

www.contester.ru