#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.

NN groups stand in line for the roller coaster, and the groups are numbered from 11 to NN. The group ii has aia_i people. People in line ride the roller coaster in ascending order of group number.

The first roller coaster departs at time 00 and departs every minute thereafter. The roller coaster can hold up to MM 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 MM 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 NN lines. In the ii-th line, you should output the time the group ii 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 NN between 11 and 100,000100,000, and an integer MM between 11 and 10910^9, inclusive. NN represents the number of groups, and MM represents the capacity of the roller coaster.

The second line consists of NN integers between 11 and MM, inclusive. For each ii (1iN1 \leq i \leq N), aia_i represents the number of people in the group ii.

输出格式

Output NN lines. In the ii-th line, you should output the answer for the group ii.

3 5
2 4 1
0
1
1
2 1000000000
1000000000 1000000000
0
1