0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-27 04:52:00 +00:00
OI-codes/Luogu/AT1894/AT1894.cpp

19 lines
344 B
C++
Raw Normal View History

2020-10-27 13:53:21 +00:00
#include <bits/stdc++.h>
using namespace std;
long long n, k, a[100005], f[100005], ans;
int main() {
cin >> n >> k;
for (long long i = 1; i <= n; i++) {
cin >> a[i];
f[i] = f[i - 1] + a[i];
}
for (long long i = k; i <= n; i++) {
ans += f[i] - f[i - k];
}
cout << ans << endl;
return 0;
}