CF1070D.Garbage Disposal

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Enough is enough. Too many times it happened that Vasya forgot to dispose of garbage and his apartment stank afterwards. Now he wants to create a garbage disposal plan and stick to it.

For each of next nn days Vasya knows aia_i — number of units of garbage he will produce on the ii -th day. Each unit of garbage must be disposed of either on the day it was produced or on the next day. Vasya disposes of garbage by putting it inside a bag and dropping the bag into a garbage container. Each bag can contain up to kk units of garbage. It is allowed to compose and drop multiple bags into a garbage container in a single day.

Being economical, Vasya wants to use as few bags as possible. You are to compute the minimum number of bags Vasya needs to dispose of all of his garbage for the given nn days. No garbage should be left after the nn -th day.

输入格式

The first line of the input contains two integers nn and kk ( 1n2105,1k1091 \le n \le 2\cdot10^5, 1 \le k \le 10^9 ) — number of days to consider and bag's capacity. The second line contains nn space separated integers aia_i ( 0ai1090 \le a_i \le 10^9 ) — the number of units of garbage produced on the ii -th day.

输出格式

Output a single integer — the minimum number of bags Vasya needs to dispose of all garbage. Each unit of garbage should be disposed on the day it was produced or on the next day. No garbage can be left after the nn -th day. In a day it is allowed to compose and drop multiple bags.

输入输出样例

  • 输入#1

    3 2
    3 2 1
    

    输出#1

    3
    
  • 输入#2

    5 1
    1000000000 1000000000 1000000000 1000000000 1000000000
    

    输出#2

    5000000000
    
  • 输入#3

    3 2
    1 0 1
    

    输出#3

    2
    
  • 输入#4

    4 4
    2 8 4 1
    

    输出#4

    4
    
首页