#abc353b. B - AtCoder Amusement Park

B - AtCoder Amusement Park

Score: 200200 points

问题陈述

AtCoder 游乐园有一个可以容纳 KK 人的游乐设施。现在,有 NN 个团队在排队等待这个游乐设施。

从前面数第 ii 个团队 (1iN)(1\leq i\leq N)AiA_i 人组成。对于所有的 ii (1iN)(1\leq i\leq N),都有 AiKA_i \leq K

高桥作为这个游乐设施的工作人员,将按照以下程序引导排队的团队。

最初,没有人被引导到游乐设施,有 KK 个空座位。

  1. 如果队列中没有团队,启动游乐设施并结束引导。
  2. 将游乐设施中的空座位数量与队列最前面的团队的人数进行比较,并执行以下操作之一:
    • 如果空座位数量少于队列最前面团队的人数,启动游乐设施。然后,空座位数量再次变为 KK
    • 否则,将队列最前面的整个团队引导到游乐设施。前面的团队从队列中移除,空座位数量减少该团队的人数。
  3. 返回步骤 1。

在这里,引导开始后不会有额外的团队排队。在这些条件下,可以证明这个程序将在有限的步骤内结束。

确定在整个引导过程中游乐设施将启动多少次。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

The AtCoder amusement park has an attraction that can accommodate KK people. Now, there are NN groups lined up in the queue for this attraction.

The ii-th group from the front (1iN)(1\leq i\leq N) consists of AiA_i people. For all ii (1iN)(1\leq i\leq N), it holds that AiKA_i \leq K.

Takahashi, as a staff member of this attraction, will guide the groups in the queue according to the following procedure.

Initially, no one has been guided to the attraction, and there are KK empty seats.

  1. If there are no groups in the queue, start the attraction and end the guidance.
  2. Compare the number of empty seats in the attraction with the number of people in the group at the front of the queue, and do one of the following:
    • If the number of empty seats is less than the number of people in the group at the front, start the attraction. Then, the number of empty seats becomes KK again.
    • Otherwise, guide the entire group at the front of the queue to the attraction. The front group is removed from the queue, and the number of empty seats decreases by the number of people in the group.
  3. Go back to step 1.

Here, no additional groups will line up after the guidance has started. Under these conditions, it can be shown that this procedure will end in a finite number of steps.

Determine how many times the attraction will be started throughout the guidance.

Constraints

  • 1N1001\leq N\leq 100
  • 1K1001\leq K\leq 100
  • 1AiK (1iN)1\leq A_i\leq K\ (1\leq i\leq N)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \ldots ANA_N

Output

Print the answer.

Sample Input 1

7 6
2 5 1 4 1 2 3

Sample Output 1

4

Initially, the seven groups are lined up as follows:

Part of Takahashi's guidance is shown in the following figure:

  • Initially, the group at the front has 22 people, and there are 66 empty seats. Thus, he guides the front group to the attraction, leaving 44 empty seats.
  • Next, the group at the front has 55 people, which is more than the 44 empty seats, so the attraction is started.
  • After the attraction is started, there are 66 empty seats again, so the front group is guided to the attraction, leaving 11 empty seat.
  • Next, the group at the front has 11 person, so they are guided to the attraction, leaving 00 empty seats.

In total, he starts the attraction four times before the guidance is completed. Therefore, print 4.

Sample Input 2

7 10
1 10 1 10 1 10 1

Sample Output 2

7

Sample Input 3

15 100
73 8 55 26 97 48 37 47 35 55 5 17 62 2 60

Sample Output 3

8