题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1081
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn=100+5;
const int INF=0x3f3f3f3f;
int Grid[maxn][maxn],d[maxn];
int MaxSum(int n)
{int ans=-INF,temp=0;for(int i=0;i<n;i++){if(temp>0) temp+=d[i];else temp=d[i];ans=max(ans,temp);}return ans;
}
int solve(int n)
{int ans=-INF;for(int i=0;i<n;i++){memset(d,0,sizeof(d));for(int j=i;j<n;j++){for(int k=0;k<n;k++)d[k]+=Grid[j][k];ans=max(ans,MaxSum(n));}}return ans;
}
int main(int argc, char const *argv[])
{int n; while(cin>>n){ for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf("%d",&Grid[i][j]);cout<<solve(n)<<endl;;}return 0;
}