1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| #include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <queue> #include <deque> #include <cstring> #include <cmath> #include <stack> #include <map> #include <set> #include <list> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <unordered_map> using namespace std; #pragma GCC optimize(1) #pragma GCC optimize(2) #pragma GCC optimize(3) #define rep(i,a,n) for (int i=a;i<=n;i++) #define per(i,a,n) for (int i=a;i>=n;i--) #define pb push_back #define mp make_pair #define fi first #define se second #define pll pair<ll,ll> #define pii pair<int,int> #define bg begin #define rbg rbegin #define ed end #define endl '\n' #define dbg(x) cout << #x << "===" << x << endl typedef double db; typedef long long ll; typedef unsigned long long ull;
int num[110][110];
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; a = (a * a) % mod, b >>= 1; } return ans % mod; }
int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; rep(i, 1, n) { rep(j, 1, n) { int x; cin >> x; num[i][j] = num[i - 1][j] + x; } } int ans = -1e9; rep(i, 1, n) { rep(j, i, n) { int res = 0; rep(k, 1, n) { int t = num[j][k] - num[i - 1][k]; res = max(res, 0) + t; ans = max(ans, res); } } } cout << ans << endl; return 0; }
|