CF11A.Increasing Sequence
入门
通过率:0%
时间限制:1.00s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A sequence _a_0, _a_1, ..., a__t - 1 is called increasing if a__i - 1 < a__i for each i: 0 < i < t.
You are given a sequence _b_0, _b_1, ..., b__n - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the given sequence increasing?
序列 a0,a1,…,at−1 被称为严格递增的,当且仅当对每个 i(其中 0<i<t)都有 ai−1<ai。
给定一个序列 b0,b1,…,bn−1 和一个正整数 d。在每次操作中,你可以选择该序列中的一个元素,并将其增加 d。问:最少需要多少次操作,才能使给定序列变为严格递增序列?
输入格式
The first line of the input contains two integer numbers n and d (2 ≤ n ≤ 2000, 1 ≤ d ≤ 106). The second line contains space separated sequence _b_0, _b_1, ..., b__n - 1 (1 ≤ b__i ≤ 106).
输入的第一行包含两个整数 n 和 d(2 ≤ n ≤ 2000,1 ≤ d ≤ 106)。第二行包含由空格分隔的序列 b0,b1,...,bn−1(1 ≤ bi ≤ 106)。
输出格式
Output the minimal number of moves needed to make the sequence increasing.
输出使序列变为严格递增所需的最少移动次数。
输入输出样例
输入#1
4 2 1 3 3 2
输出#1
3
输入解题思路,AI测评打分。不知道怎么写?