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.

23 lines
444 B

#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
const int INF = 0x3f3f3f3f;
int a[N];
int mi = 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++) {
int sum = 0;
for (int j = 0; j < m; j++)
sum += a[i + j];
mi = min(mi, sum);
}
cout << mi << endl;
return 0;
}