0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 05:18:49 +00:00

P5638 【CSGRound2】光骓者的荣耀

R52267925
This commit is contained in:
Baoshuo Ren 2021-07-02 07:40:04 +08:00 committed by Baoshuo Ren
parent bfffd4fb8a
commit 8c040f9ff7
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,20 @@
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long a, cnt, sum[1000005];
int main() {
cin >> n >> k;
for (int i = 1; i < n; i++) {
cin >> a;
sum[i] = sum[i - 1] + a;
}
cnt = sum[k];
for (int i = 2; i <= n - k; i++) {
cnt = max(cnt, sum[i + k - 1] - sum[i - 1]);
}
cout << sum[n - 1] - cnt << endl;
return 0;
}