标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10233 Accepted Submission(s): 4923
#include<stdio.h>
#include<string.h>
int a[105][105],n,b[2][105],c[105],dp[105];
int max(int x,int y)
{
if(x>y)
return x;
return y;
}
int L()
{
int i,m=-9999;
dp[0]=0;
for(i=1; i<=n; i++)
{
dp[i]=max(dp[i-1]+c[i],dp[i]);
if(m<dp[i])
m=dp[i];
}
return m;
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
int i,j,k,m,Max=-99999;
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
scanf("%d",&a[i][j]);
for(i=1; i<=n; i++)
{
memset(b,0,sizeof(b));
for(k=i; k<=n; k++)
{
for(j=1; j<=n; j++)
{
dp[j]=c[j]=b[k%2][j]=b[(k-1)%2][j]+a[k][j];
}
m=L();
if(Max<m)
Max=m;
}
}
printf("%d\n",Max);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/-lgh/p/4966826.html