From e1bb425d870337cc4b629d6a7090209505a96024 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 30 Dec 2020 18:25:28 +0800 Subject: [PATCH] =?UTF-8?q?AT2412=20[JOI=202007=20Final]=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E3=81=AE=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R44429693 --- problem/AT2412/AT2412.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 problem/AT2412/AT2412.cpp diff --git a/problem/AT2412/AT2412.cpp b/problem/AT2412/AT2412.cpp new file mode 100644 index 00000000..1a1871af --- /dev/null +++ b/problem/AT2412/AT2412.cpp @@ -0,0 +1,18 @@ +#include + +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; +}