Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <stdio.h>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <deque>
- #include <ctime>
- #include <iterator>
- using namespace std;
- const int INF = (int)(2e9);
- typedef long long ll;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- #define mh() make_heap()
- #define poph() pop_heap()
- #define pushh() push_heap()
- #define sor(n) n.begin(), n.end()
- #define mp make_pair
- #define files freopen("secretroom.in", "rt", stdin); freopen("secretroom.out", "wt", stdout)
- int main()
- {
- ll n;
- cin >> n;
- int arr[101][101];
- int min = -1e9;
- for (int i = 1; i <= n; i++)
- {
- arr[i][0] = 0;
- for (int j = 1; j <= n; j++)
- {
- int prom;
- cin >> prom;
- if (prom < 0)
- if (prom > min)
- min = prom;
- arr[i][j] = arr[i][j - 1] + prom;
- }
- }
- int Max = -1e8;
- for(int i=1;i<=n;i++)
- for (int j = i; j <= n; j++)
- {
- ll maxx = 0;
- for (int o = 1; o <= n; o++)
- {
- maxx = 0;
- for (int u = o; u <= n; u++)
- {
- maxx += arr[u][j] - arr[u][i - 1];
- if (maxx > Max)
- Max = maxx;
- }
- }
- }
- cout << max(Max,min);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement