Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- int main() {
- int n, arr[101][101] = {};
- while (scanf("%d", &n) != EOF) {
- for (int i = 1; i <= n; ++i) {
- for (int j = 1; j <= n; ++j) {
- scanf("%d", &arr[i][j]);
- }
- }
- int col_sum[101][101] = {};
- for (int i = 1; i <= n; ++i) {
- for (int j = 1; j <= n; ++j) {
- col_sum[i][j] = col_sum[i - 1][j] + arr[i][j];
- }
- }
- int ans = -128, sum;
- for (int i = 0; i <= n; ++i) {
- for (int j = i + 1; j <= n; ++j) {
- sum = 0;
- for (int row = 1; row <= n; ++row) {
- sum = sum + col_sum[j][row] - col_sum[i][row];
- if (sum > ans) ans = sum;
- if (sum < 0) sum = 0;
- }
- }
- }
- printf("%d\n", ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement