璟雯院

珺璟如晔,雯华若锦

用户工具

站点工具


icpc:problems:usaco23feb_watching_mooloo_b
problems
名称Watching Mooloo B
题目编号USACO23FEB_B3
题目链接luogu.com.cn/…
来源USACO
算法分类递推, 动态规划
难易程度容易

Watching Mooloo B

想法

第一天必订阅,之后每一天判断是连续上一次的订阅还是新开订阅即可。

代码实现

#include<cstdio>
 
int main()
{
	int n, k;
	long long int ans, temp, before;
	scanf("%d %d", &n, &k);
	ans = k + 1;
	scanf("%lld", &before);
	for(int i=2; i<=n; i++) {
		scanf("%lld", &temp);
		if(temp - before < k + 1)
			ans += temp-before;
		else
			ans += k+1;
		before = temp;
	}	
	printf("%lld", ans);
	return 0;
} 
/app/www/public/data/pages/icpc/problems/usaco23feb_watching_mooloo_b.txt · 最后更改: 2023/05/02 09:43 由 温婕莺