Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这个,,在杭电上也能A(考虑了全为负的情况)

Posted by 123Go_Go_Go at 2012-10-16 20:45:02 on Problem 1050
#include<iostream>
using namespace std;
int main()
{
	int A[200][200]={0};
	int N,i,j,k;
	while(~scanf("%d",&N))
	{
		for(i=0;i<N;i++)
		{
			for(j=0;j<N;j++)
			{
				cin>>A[i][j];
			}
		}
		int B[200][200]={0};
		int max=A[0][0];

		int s=0;
		for(j=0;j<N;j++)
		{
			for(i=0;i<N;i++)
			{
				B[i][j]=s+A[i][j];
				s=B[i][j];
			}
			s=0;
		}

		s=0;
		for(k=0;k<N;k++)
		{
			for(i=k;i<N;i++)
			{
				for(j=0;j<N;j++)
				{
					if(i==k)
						s+=A[i][j];
					else
					{
						if(k==0)
							s+=B[i][j];
						else
						{
							if(k==0)
							    s+=B[i][j];
							else
								s+=B[i][j]-B[k-1][j];
						}
					}
					
					if(s>max && s!=0)
						max=s;
					if(s<0)
						s=0;
				}
				s=0;
			}
		}
		cout<<max<<endl;
	}	

	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator