HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Problems from Olympiads.ru > problem:


206. 50252 - Birthday

Guest
• Discussion of problem (1)

Volume problems

• 127b. 50730 - The largest product
• 127c. 50731 - The largest product (2)
• 138. 50732 - Sorting
• 147. 50251 - Symmetric matrix
• 213. 50769 - Arithmetic expression
• 217. 50253 - Timer
• 133. 50239 - Eating cheese
• 159. 50668 - Triangle
• 206. 50252 - Birthday
• 234. 50249 - Ladders
• 235. 50250 - The Knight
• 272. 50707 - Rebus
• 240. 50247 - Missing numbers
• 275. 50691 - The traveling salesma...

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