From e422afcb107644b08add29d2626ab1603a144d55 Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Tue, 18 Aug 2026 19:45:25 +0800 Subject: [PATCH] new file: P1719.cpp --- P1719.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 P1719.cpp diff --git a/P1719.cpp b/P1719.cpp new file mode 100644 index 0000000..e37e812 --- /dev/null +++ b/P1719.cpp @@ -0,0 +1,24 @@ +// 126 +#include +using namespace std; +int n, m, k, a[105][105], sum[105][105]; +int query(int xx1, int yy1, int xx2, int yy2) +{ + return sum[xx2][yy2] - sum[xx1 - 1][yy2] - sum[xx2][yy1 - 1] + sum[xx1 - 1][yy1 - 1]; +} +int main() +{ + scanf("%d", &n); + for (int i = 1; i <= n; ++i) + for (int j = 1; j <= n; ++j) + scanf("%d", &a[i][j]), sum[i][j] = a[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]; + int ans = -2147482648; + for (int xx1 = 1; xx1 <= n; ++xx1) + for (int yy1 = 1; yy1 <= n; ++yy1) + for (int xx2 = xx1; xx2 <= n; ++xx2) + for (int yy2 = yy1; yy2 <= n; ++yy2) + if (query(xx1, yy1, xx2, yy2) > ans) + ans = query(xx1, yy1, xx2, yy2); + printf("%d", ans); + return 0; +} \ No newline at end of file