0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-02 23:56:29 +00:00
OI-codes/Luogu/AT2412/AT2412.cpp

19 lines
335 B
C++
Raw Normal View History

#include <bits/stdc++.h>
using namespace std;
int n, k, ans, a[100005], f[100005];
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
f[i] = f[i - 1] + a[i];
}
for (int i = k; i <= n; i++) {
ans = max(ans, f[i] - f[i - k]);
}
cout << ans << endl;
return 0;
}