0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

AT1894 総和

R40651953
This commit is contained in:
Baoshuo Ren 2020-10-27 21:53:21 +08:00 committed by Baoshuo Ren
parent 3b2b0091a8
commit 7678d77761
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

18
problem/AT1894/AT1894.cpp Normal file
View File

@ -0,0 +1,18 @@
#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;
}