From ce652771f3b01c04295a9580793e3d33feb140c4 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 2 Apr 2022 19:46:53 +0800 Subject: [PATCH] =?UTF-8?q?1282.=20=E6=9C=80=E5=A4=A7=E5=AD=90=E7=9F=A9?= =?UTF-8?q?=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://ybt.ssoier.cn:8088/statusx.php?runidx=15571621 --- ybt/1282/1282.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ybt/1282/1282.cpp diff --git a/ybt/1282/1282.cpp b/ybt/1282/1282.cpp new file mode 100644 index 00000000..c4d8c579 --- /dev/null +++ b/ybt/1282/1282.cpp @@ -0,0 +1,41 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 105; + +int n, g[N][N], sum[N], f[N], ans = -0x3f3f3f3f; + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + cin >> g[i][j]; + } + } + + for (int i = 1; i <= n; i++) { + for (int j = i; j <= n; j++) { + for (int k = 1; k <= n; k++) { + sum[k] = 0; + for (int l = i; l <= j; l++) { + sum[k] += g[k][l]; + } + } + + f[0] = -0x3f3f3f3f; + for (int k = 1; k <= n; k++) { + f[k] = std::max(f[k - 1] + sum[k], sum[k]); + ans = std::max(ans, f[k]); + } + } + } + + cout << ans << endl; + + return 0; +}