EM_LGH CF965D Single-use Stones 思维_推理

Code:

#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1000000 + 3;
long long  arr[maxn], ans[maxn], sumv[maxn];
int main()
{
	int T = 1;
	while(T--){
		int w, l;
		scanf("%d%d",&w,&l);
		for(int i = 1;i <= w - 1; ++i) {
			scanf("%lld",&arr[i]);
			sumv[i] = sumv[i - 1] + arr[i];
		}
		long long  ans = 1000000000000000;
		for(int i = 0;i + l < w; ++i)
		{
			ans = min(ans, sumv[i + l] - sumv[i]);
		}
		
		printf("%d\n", ans);
	}
	return 0;
}
posted @ 2018-10-16 14:23  EM-LGH  阅读(117)  评论(0编辑  收藏  举报