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 b>
Td>
|
Input 2 b>
Td>
|
Input 3 b>
Td> tr>
5
4 4
0 3
1 4
1 3
2 2
Td>
|
3
1 1
1 1
1 1
Td>
|
1
0 0
Td> tr> |
Output 1 b>
Td>
|
Output 2 b>
Td>
|
Output 3 b>
Td> tr>
1
Td>
|
0
Td>
|
1
Td> tr> | | |
Для отправки решений необходимо выполнить вход.
|