0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 16:32:02 +00:00

AT2412 [JOI 2007 Final]最大の和

R44429693
This commit is contained in:
Baoshuo Ren 2020-12-30 18:25:28 +08:00 committed by Baoshuo Ren
parent e78eb6db61
commit e1bb425d87
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

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

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