题意
解析
前缀和水题,就是在所有长度为k的区间里找个最小的。
代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10,M = 1e6 + 10;
int n,m,a[N];
int main(){
cin >> n >> m;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
a[i] += a[i-1];
}
int Min = 1 << 30,pos;
// cout << res;
for(int i=m;i<=n;i++){
if(Min > a[i] - a[i-m]){
Min = a[i] - a[i-m];
pos = i-m+1;
}
}
cout << pos;
return 0;
}
标签:CF363B,题意,10,int,long,1100
From: https://www.cnblogs.com/dtdbm/p/17009290.html