#P15718. [JAG 2023 Summer Camp #3] Roller Coaster
[JAG 2023 Summer Camp #3] Roller Coaster
题目描述
In Japan Amusement Group (JAG), members discuss how to have better amusement to attract many people. These days, they are interested in reducing waiting time stress.
As a member of JAG, you found out the hypothesis that knowing waiting time can reduce such kind of stress. Therefore, you decided to write a program which presumes the waiting time of a roller coaster.
groups stand in line for the roller coaster, and the groups are numbered from to . The group has people. People in line ride the roller coaster in ascending order of group number.
The first roller coaster departs at time and departs every minute thereafter. The roller coaster can hold up to people.
For each group, the whole group member must ride the roller coaster at the same time. Additionally, there is no need to get exactly people on the roller coaster at one time. Each group wants to ride the roller coaster as soon as possible, so they ride it if they can.
You should output lines. In the -th line, you should output the time the group can ride the roller coaster.
输入格式
$$\begin{aligned} &N \ M \\ &a_1 \ a_2 \ \ldots \ a_N \end{aligned} $$The first line consists of an integer between and , and an integer between and , inclusive. represents the number of groups, and represents the capacity of the roller coaster.
The second line consists of integers between and , inclusive. For each (), represents the number of people in the group .
输出格式
Output lines. In the -th line, you should output the answer for the group .
3 5
2 4 1
0
1
1
2 1000000000
1000000000 1000000000
0
1