#BS0000239. Vườn cây tại nhà (Home Garden)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Vườn cây tại nhà (Home Garden)
Home Garden
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Takahashi owns pots, initially without plants. Process operations in order: 1 plants a new plant of height zero in a vacant pot; 2 T advances time by days and increases each living plant's height by ; 3 H removes all plants of height at least and reports their count. Planting and harvesting take no time.
Input
The first line contains integer . The next lines each contain 1, 2 T, or 3 H as described, with integer .
Output
For each type-3 operation, print the number of plants removed on its own line.
Subtasks
- Subtask 1 (20 points): ; whenever present; at least one type-3 operation.
- Subtask 2 (30 points): ; whenever present; at least one type-3 operation; all type-1 operations precede every type-2 or type-3 operation.
- Subtask 3 (50 points): ; whenever present; at least one type-3 operation.
Examples
Input
7
1
2 4
1
3 4
2 3
3 3
3 1
Output
1
1
0
Explanation
After four days the first plant is 4 tall. The second starts at zero. Harvesting at 4 removes the first. Three days later the remaining plant reaches 3 and is removed. The final harvest is empty.