mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 18:16:26 +00:00
P5638 【CSGRound2】光骓者的荣耀
R52267925
This commit is contained in:
parent
bfffd4fb8a
commit
8c040f9ff7
20
Luogu/problem/P5638/P5638.cpp
Normal file
20
Luogu/problem/P5638/P5638.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user