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.
24 lines
488 B
24 lines
488 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int a[3001] = {0};
|
|
int _min = 999999;
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(false); //读入输出优化的强迫症
|
|
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 = 1; j <= m; j++) {
|
|
sum += a[i + j-1];
|
|
}
|
|
if (_min > sum) _min = sum;
|
|
}
|
|
cout << _min << endl;
|
|
return 0;
|
|
} |