Infinitely Bursting Bubbles in a Glass Bottle
Time limit3sMemory limit1024 MB
Simulate bubbles across N zones over T seconds, adding bubbles to a given zone then spreading them up and down, and print the total each second.
- Level
Medium6 of 10
- Topics
- Simulation, Array, Segment tree
- Solved
- No attempts yet
Problem
너에게서는 멸종된 과일 향기가 난다
투룸 신축 빌라 보증금 이천에 월세 구십, 어떻게 해야 너를 웃길 수 있을까 하는 생각, 두 시간 동안의 폭우, 일주일 동안의 아침, 유리병 속 무한히 터지는 기포
-고선경, [샤워젤과 소다수]
A tall, thin glass bottle stands upright. Inside it, bubbles burst endlessly.
Scientist Jeongwoo became curious about this phenomenon and kept observing it. He found the following facts. First, divide the bottle vertically into equal parts, forming zones from zone at the bottom to zone at the top. Each zone can hold at most bubbles. At the start, no zone has any bubbles. Every second, the following two phenomena occur in turn, in this order.
- Bubble creation: Bubbles are created in one zone of the bottle. At the -th creation, bubbles are created in zone . If the sum of the bubbles already in that zone and the newly created bubbles exceeds , only bubbles remain and the rest disappear.
- Bubble movement: Bubbles in all zones move up or down at the same time. If zone has bubbles, then bubbles move to the zone directly above, bubbles move to the zone directly below, bubbles stay in place, and the remaining bubbles disappear. A bubble that tries to move below zone or above zone disappears. After movement, if any zone has more than bubbles, only remain and the rest disappear.
Figure 1. (a) The bottle divided into zones. (b) Bubble movement at zone and zone .
Jeongwoo wants to write a program that models how bubbles move in the bottle. Let be the total number of bubbles left in the bottle after seconds, that is, after rounds of bubble creation and bubble movement. Given the observation time , find the values of .
Input
The first line contains three integers , , and , separated by spaces: the number of zones, the maximum number of bubbles each zone can hold, and the observation time. (, , )
From the second line onward, the next lines each contain, for the -th creation, the zone number where bubbles are created and the number of bubbles created there, separated by a space. (, )
Output
Print lines. On line , print .
Hint
is the floor function, which gives the largest integer less than or equal to the real number .