hdu1081

/*
分析:
    DP+压缩。
虽然31MS,不过这两天写的DP,首次一次ac,还是挺兴奋的
O(∩_∩)O~
    其实- -III,max不能初始为零的,因为,最大值可能为负……


                                        2012-05-04
*/






#include"stdio.h"
#include"string.h"
int main()
{
	int num[105][105];
	int i1,i2,i_temp,l;
	int temp[105];
	int n;
	int max;
	int temp0;
	while(scanf("%d",&n)!=-1)
	{
		for(i1=0;i1<n;i1++)
		for(l=0;l<n;l++)
			scanf("%d",&num[i1][l]);


		max=0;
		for(i2=0;i2<n;i2++)
		{
			for(i1=0;i1<=i2;i1++)
			{
				/*****/                  //压缩
				for(l=0;l<n;l++)
				{
					temp0=0;
					for(i_temp=i1;i_temp<=i2;i_temp++)	temp0+=num[i_temp][l];
					temp[l]=temp0;
				}
				/*****/


				if(temp[0]>max)	max=temp[0];
				for(l=1;l<n;l++)
				{
					if(temp[l-1]>0)	temp[l]+=temp[l-1];
					if(temp[l]>max)	max=temp[l];
				}
			}
		}


		printf("%d\n",max);
	}
	return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值