0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:05:26 +00:00

P1725 琪露诺

https://www.luogu.com.cn/record/86099060
This commit is contained in:
Baoshuo Ren 2022-09-08 10:20:15 +08:00
parent aabd9221e1
commit 85613cc078
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

39
Luogu/P1725/P1725.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <iostream>
#include <algorithm>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e5 + 5;
int n, l, r, a[N << 1];
long long f[N << 1], ans = std::numeric_limits<int>::min();
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
std::fill_n(f + 1, (N << 1) - 1, std::numeric_limits<int>::min());
cin >> n >> l >> r;
for (int i = 0; i <= n; i++) {
cin >> a[i];
}
for (int i = l; i < n + r; i++) {
for (int j = std::max(i - r, 0); j <= i - l; j++) {
f[i] = std::max(f[i], f[j] + a[i]);
}
}
for (int i = n; i < n + r; i++) {
ans = std::max(ans, f[i]);
}
cout << ans << endl;
return 0;
}