我是靠谱客的博主 老迟到糖豆,这篇文章主要介绍CodeForces - 11A Increasing Sequence,现在分享给大家,希望可以做个参考。

题意:给一个含n个数的数列,给其中一个数加d算一次操作,问最少操作几次可以让数列变成严格单调增的。

看别人博客时偶然碰到的水题……

#include <cstdio>

int main ()
{
	int n,d;
	while (~scanf("%d%d",&n,&d))
	{
		int time=0,fir,sec,temp;
		scanf("%d",&fir);
		for (int i=2;i<=n;i++)
		{
			scanf("%d",&sec);
			if (fir>sec)
			{
				temp=(fir-sec)/d+1;
				time+=temp;
				sec+=temp*d;
			}
			else if (fir == sec)
				time++,sec+=d;
			fir=sec;
		}
		printf("%dn",time);
	}
	return 0;
}


最后

以上就是老迟到糖豆最近收集整理的关于CodeForces - 11A Increasing Sequence的全部内容,更多相关CodeForces内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(117)

评论列表共有 0 条评论

立即
投稿
返回
顶部