Increasing Sequence CodeForces - 11A

原题链接

考察:贪心

思路:

        这是构造递增序列不是等差递增序列!!!看了半天没想出来怎么写,结果发现看错题目了555

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 using namespace std;
 5 typedef long long LL;
 6 const int N = 2010;
 7 int a[N],d,ans,n;
 8 int main() 
 9 {
10     scanf("%d%d",&n,&d);
11     for(int i=1;i<=n;i++) scanf("%d",&a[i]);
12     for(int i=2;i<=n;i++)
13     {
14         if(a[i]>a[i-1]) continue;
15         ans+= (a[i-1]-a[i])/d+1;
16         a[i] +=((a[i-1]-a[i])/d+1)*d;
17     }
18     printf("%d\n",ans);
19     return 0;
20 }

 

posted @ 2021-03-26 00:19  acmloser  阅读(27)  评论(0编辑  收藏  举报