Professional Documents
Culture Documents
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
<iostream>
<cstdio>
<cstdlib>
<cstring>
<string>
<cctype>
<cmath>
<iomanip>
<algorithm>
<stack>
<queue>
<map>
<set>
<vector>
<climits>
<sstream>
#define pb push_back
#define SC(a) scanf("%d", &a)
#define STR( x ) dynamic_cast< std::ostringstream & >( \
( std::ostringstream() << std::dec << x ) ).str()
int table[705][705];
int calc(int r1, int c1, int r2, int c2)
{
return table[r2][c2] - table[r1-1][c2] - table[r2][c1-1] + table[r1-1][c
1-1];
}
int main()
{
ios_base::sync_with_stdio(false);
int n, r[105][105];
cin>>n;
FOR(i, 1, n){
FOR(j, 1, n){
cin>>r[i][j];
}
}
//Table
SET(table, 0);
FOR(i, 1, n){
FOR(j, 1, n){
table[i][j]=table[i-1][j] + table[i][j-1] - table[i-1][j
-1] + r[i][j];
}
}
int mx=INT_MIN;
FOR(i, 1, n){
FOR(j, 1, n){
FOR(k, i, n){
FOR(l, j, n){
mx=max(mx, calc(i, j, k, l));
}
}
}
}
cout<<mx<<endl;
}