From 378581f5fb831f3525fe3345521150f9566d048c Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Tue, 30 Nov 2021 19:11:14 +0800 Subject: [PATCH] =?UTF-8?q?P2280=20[HNOI2003]=E6=BF=80=E5=85=89=E7=82=B8?= =?UTF-8?q?=E5=BC=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R63978323 --- Luogu/P2280/P2280.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Luogu/P2280/P2280.cpp diff --git a/Luogu/P2280/P2280.cpp b/Luogu/P2280/P2280.cpp new file mode 100644 index 00000000..1a37f4f4 --- /dev/null +++ b/Luogu/P2280/P2280.cpp @@ -0,0 +1,27 @@ +#include + +using std::cin; +using std::cout; +using std::endl; + +int n, m, x, y, v, ans, g[5005][5005]; + +int main() { + cin >> n >> m; + for (int i = 1; i <= n; i++) { + cin >> x >> y >> v; + g[x + 1][y + 1] = v; + } + for (int i = 1; i <= 5001; i++) { + for (int j = 1; j <= 5001; j++) { + g[i][j] += g[i][j - 1] + g[i - 1][j] - g[i - 1][j - 1]; + } + } + for (int i = m; i <= 5001; i++) { + for (int j = m; j <= 5001; j++) { + ans = std::max(ans, g[i][j] - g[i - m][j] - g[i][j - m] + g[i - m][j - m]); + } + } + cout << ans << endl; + return 0; +}