atcoder#ABC240D. [ABC240D] Strange Balls
[ABC240D] Strange Balls
Score : points
Problem Statement
Takahashi has balls. Each ball has an integer not less than written on it. He will insert them in a cylinder one by one. The integer written on the -th ball is .
The balls are made of special material. When balls with written on them line up in a row, all these balls will disappear.
For each , find the number of balls after inserting the -th ball.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the number of balls after inserting the -th ball.
5
3 2 3 2 2
1
2
3
4
3
The content of the cylinder changes as follows.
- After inserting the -st ball, the cylinder contains the ball with .
- After inserting the -nd ball, the cylinder contains from bottom to top.
- After inserting the -rd ball, the cylinder contains from bottom to top.
- After inserting the -th ball, the cylinder contains from bottom to top.
- After inserting the -th ball, the cylinder momentarily has from bottom to top. The two consecutive balls with disappear, and the cylinder eventually contains from bottom to top.
10
2 3 2 3 3 3 2 3 3 2
1
2
3
4
5
3
2
3
1
0