atcoder#TENKA12017B. Different Distribution
Different Distribution
Score : points
Problem Statement
A group of people played a game. All players had distinct scores, which are positive integers.
Takahashi knows facts on the players' scores. The -th fact is as follows: the -th highest score among the players is .
Find the maximum possible number of players in the game.
Constraints
- If , .
- There exists a possible outcome of the game that are consistent with the facts.
- All input values are integers.
Inputs
Input is given from Standard Input in the following format:
:
Outputs
Print the maximum possible number of players in the game.
3
4 7
2 9
6 2
8
The maximum possible number of players is achieved when, for example, the players have the following scores: .
5
1 10
3 6
5 2
4 4
2 8
7
2
1 1000000000
1000000000 1
1000000001