如何用最少步数将序列变为递增序列
A sequence \u00b00,\u00b11,...,\u00b0\u00b0−\u00b11b\u00b0\u00b10,b\u00b11,...,b\u00b1n−\u00b11 is called increasing if \u00b0\u00b0−\u00b11<\u00b0\u00b0a\u00b1i−\u00b11<a\u00b1i for each \u00b0:0<\u00b0<\u00b0i:0<i<t.
You are given a sequence \u00b00,\u00b11,...,\u00b0\u00b0−\u00b11b\u00b0\u00b10,b\u00b11,...,b\u00b1n−\u00b11 and a positive integer \u00b0d. In each move you may choose one element of the given sequence and add \u00b0d 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 \u00b0n and \u00b0d ( 2<=\u00b0n<=2000,1<=\u00b0d<=10\u00b06). The second line contains space separated sequence \u00b00,\u00b11,...,\u00b0\u00b0−\u00b11b\u00b0\u00b10,b\u00b11,...,b\u00b1n−\u00b11 ( 1<=\u00b0\u00b0<\u00b010\u00b061<=b\u00b1i<=10\u00b06 ).
输出格式
Output the minimal number of moves needed to make the sequence increasing.
c++实现内容:#include
原文地址: https://www.cveoy.top/t/topic/pRDe 著作权归作者所有。请勿转载和采集!