The World
You've just been paid and can't wait to spend it all at the world-famous casino, The World. Sadly, a world-famous casino comes with world-famous (long) lines to get in. Just as you get to the front of the line, a bunch of people cut in front of the you! Those jerks!
With nothing else to do, you find yourself staring at the backs of the line-cutters' heads. You notice something interesting: taller people block the view of anyone shorter in front of them. In other words, can only see someone if they are strictly taller than everyone behind them. So, every time someone cuts into the line, the number of people you can see will change.
Out of sheer boredom, you decide to keep track of how many people are visible in the line after each new person pushes in.
Input
The first line consists of an integer
, the number of people who enter the line.
Each of the next lines contains two integers
and
:
is the position the person takes in line (larger
means further toward the front).
is the height of the person in centimeters.
People are added to the line in the order given — each one cuts into their specified position.
Output
For each person who enters the line, print a single integer, the number of people you can see after they join the line.
Clarifications
- You start with no one ahead of you in line.
- Everyone who joins the line will be in front of you. In other words, you are at position
.
Example
Input 1
5
4 4
6 1
8 6
5 5
1 5
Output 1
1
1
2
3
2
- At position
, someone
cm tall appears. You can see them.
- At position
, someone
cm tall appears. You can't see them, because the person at position
is blocking them.
- At position
, someone
cm tall appears. You can see them.
- At position
, someone
cm tall appears. You can see them.
- At position
, someone
cm tall appears. You can see them, but the block the people at position
and
.
Here's a visual representation of this case. You are the blue person. The red people are people you can see.
Input 2
5
1 1
2 2
3 3
4 4
5 5
Output 2
1
2
3
4
5
Input 3
7
2 2
3 3
1 10
4 4
5 5
6 6
7 7
Output 3
1
2
1
1
1
1
1
Comments