1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 using namespace std; 7 8 #define GI ({int _t; scanf("%d", &_t); _t;}) 9 #define FOR(i, a, b) for (int i=a; i<b; i++) 10 #define REP(i, a) FOR(i, 0, a) 11 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 12 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 13 #define DBGV(_v) { REP(_i, n) { cout << _v[_i] << "\t";} cout << endl;} 14 #define INF (int)1e6 15 #define MAX 101 16 17 int main() { 18 int num[MAX][MAX], prefix[MAX]; 19 int n = GI, maxsum = 0; 20 REP(i, n) REP(j, n) { scanf("%d", &num[i][j]); } 21 REP(i, n) { 22 int t = 0; 23 REP(j, n) { prefix[j] = 0; } 24 FOR (k, i, n) { 25 REP(j, n) { 26 t = 0; 27 prefix[j] += num[k][j]; 28 } 29 REP(l, n) { 30 t += prefix[l]; 31 if (t > maxsum) maxsum = t; 32 else if (t < 0) t = 0; 33 } 34 //DBGV(prefix); 35 } 36 } 37 printf("%d\n", maxsum); 38 }