atcoder#ABC170E. [ABC170E] Smart Infants
[ABC170E] Smart Infants
Score : points
Problem Statement
There are infants registered in AtCoder, numbered to , and kindergartens, numbered to . Infant has a rating of and initially belongs to Kindergarten .
From now on, transfers will happen. After the -th transfer, Infant will belong to Kindergarten .
Here, we define the evenness as follows. For each kindergarten with one or more infants registered in AtCoder, let us find the highest rating of an infant in the kindergarten. The evenness is then defined as the lowest among those ratings.
For each of the transfers, find the evenness just after the transfer.
Constraints
- All values in input are integers.
- In the -th transfer, Infant changes the kindergarten it belongs to.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the evenness just after the -th transfer.
6 3
8 1
6 2
9 3
1 1
2 2
1 3
4 3
2 1
1 2
6
2
6
Initially, Infant belongs to Kindergarten , Infant belongs to Kindergarten , and Infant belongs to Kindergarten .
After the -st transfer that makes Infant belong to Kindergarten , Infant belongs to Kindergarten , Infant belong to Kindergarten , and Infant belong to Kindergarten . The highest ratings of an infant in Kindergarten are , respectively. The lowest among them is , so the -st line in the output should contain .
After the -nd transfer that makes Infant belong to Kindergarten , Infant belong to Kindergarten , Infant belongs to Kindergarten , and Infant belong to Kindergarten . The highest ratings of an infant in Kindergarten are , respectively. The lowest among them is , so the -nd line in the output should contain .
After the -rd transfer that makes Infant belong to Kindergarten , Infant belongs to Kindergarten , Infant belong to Kindergarten , and Infant belong to Kindergarten . The highest ratings of an infant in Kindergarten are , respectively. The lowest among them is , so the -rd line in the output should contain .
2 2
4208 1234
3056 5678
1 2020
2 2020
3056
4208