CF11A.Increasing Sequence

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

A sequence a0,a1,...,at1a_{0},a_{1},...,a_{t-1} is called increasing if ai1<aia_{i-1}<a_{i} for each i:0<i<ti:0<i<t .

You are given a sequence b0,b1,...,bn1b_{0},b_{1},...,b_{n-1} and a positive integer dd . In each move you may choose one element of the given sequence and add dd to it. What is the least number of moves required to make the given sequence increasing?

输入格式

The first line of the input contains two integer numbers nn and dd ( 2<=n<=2000,1<=d<=1062<=n<=2000,1<=d<=10^{6} ). The second line contains space separated sequence b0,b1,...,bn1b_{0},b_{1},...,b_{n-1} ( 1<=bi<=1061<=b_{i}<=10^{6} ).

输出格式

Output the minimal number of moves needed to make the sequence increasing.

输入输出样例

  • 输入#1

    4 2
    1 3 3 2
    

    输出#1

    3
    
首页