You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
408 B
19 lines
408 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
const int N=3010;
|
|
const int INF=0x3f3f3f3f;
|
|
typedef long long LL;
|
|
int a[N];
|
|
LL MIN = INF;
|
|
int main() {
|
|
int n,m;
|
|
cin>>n>>m;
|
|
for (int i = 1; i <= n; i++) cin>>a[i];
|
|
for (int i = 1; i <= n-m+1; i++) {
|
|
LL sum =0;
|
|
for (int j = 1; j < m; j++) sum+=a[i+j];
|
|
MIN=min(MIN,sum);
|
|
}
|
|
cout<<MIN;
|
|
return 0;
|
|
} |