From 85613cc078223bf6e24beb6dbfd323a78420d5b5 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 8 Sep 2022 10:20:15 +0800 Subject: [PATCH] =?UTF-8?q?P1725=20=E7=90=AA=E9=9C=B2=E8=AF=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.luogu.com.cn/record/86099060 --- Luogu/P1725/P1725.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Luogu/P1725/P1725.cpp diff --git a/Luogu/P1725/P1725.cpp b/Luogu/P1725/P1725.cpp new file mode 100644 index 00000000..5bf4790c --- /dev/null +++ b/Luogu/P1725/P1725.cpp @@ -0,0 +1,39 @@ +#include +#include +#include + +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::min(); + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + std::fill_n(f + 1, (N << 1) - 1, std::numeric_limits::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; +}