#abc320e. E - Somen Nagashi
E - Somen Nagashi
Score : points
问题描述
有 人在参加一个名为“流动面条”的活动。这些人排成一排,按照从前到后的顺序编号为 到 。
在活动期间,发生了 次以下情况:
- 在时间点 ,会有数量为 的面条从上而下飘落。排头的人会得到所有面条(如果队伍中无人,则没有人得到)。然后该人离开队伍,并在时间 返回到队伍中的原始位置。
在时间 回到队伍的人被视为在时间 处于队伍之中。
经历这 次事件后,请报告每个人总共得到了多少面条。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are people gathered for an event called Flowing Noodles. The people are lined up in a row, numbered to in order from front to back.
During the event, the following occurrence happens times:
- At time , a quantity of noodles is flown down. The person at the front of the row gets all of it (if no one is in the row, no one gets it). That person then steps out of the row and returns to their original position in the row at time .
A person who returns to the row at time is considered to be in the row at time .
After all the occurrences, report the total amount of noodles each person has got.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the amount of noodles person has got.
Sample Input 1
3 5
1 1 3
2 10 100
4 100 10000
10 1000 1000000000
100 1000000000 1
Sample Output 1
101
10
1000
The event proceeds as follows:
- At time , a quantity of noodles is flown down. People , , and are in the row, and the person at the front, person , gets the noodles and steps out of the row.
- At time , a quantity of noodles is flown down. People and are in the row, and the person at the front, person , gets the noodles and steps out of the row.
- At time , person returns to the row.
- At time , a quantity of noodles is flown down. People and are in the row, and the person at the front, person , gets the noodles and steps out of the row.
- At time , a quantity of noodles is flown down. Only person is in the row, and the person at the front, person , gets the noodles and steps out of the row.
- At time , a quantity of noodles is flown down. No one is in the row, so no one gets these noodles.
- At time , person returns to the row.
- At time , person returns to the row.
- At time , person returns to the row.
The total amounts of noodles people , , and have got are , , and , respectively.
Sample Input 2
3 1
1 1 1
Sample Output 2
1
0
0
Sample Input 3
1 8
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
Sample Output 3
15
update @ 2024/3/10 01:38:52