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

求助~~~开始TL 后来又WA~~郁闷

Posted by s2009zy at 2010-05-31 18:32:48 on Problem 2479
#include<iostream>
using namespace std;

int main()
{
	int Right[50008];
	int Lift[50008];
	int Array[50008];
	int Start;
	int End;
	int i;
	int t,n;
	int max;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for( i = 1 ; i <= n ; i++ )
		{
			scanf("%d",&Array[i]) ;
		}
		End = Array[1];
		Lift[1] = Array[1];
		for( i = 2 ; i <= n ; i++ )
		{
			if(Array[i]>Array[i]+End)
			{
				End=Array[i];
			}
			else
			{
				End=Array[i]+End;
			}
			if(End>Lift[i-1])
			{
				Lift[i]=End;
			}
			else
			{
				Lift[i]=Lift[i-1];
			}
		}
		Start = Array[n] ;
		Right[n] = Array[n];
		for( i=n-1 ; i>=1 ;i-- )
		{
		
			if(Array[i]>Start+Array[i])
			{
				Start=Array[i];
			}
			else
			{
				Start+=Array[i];
			}
		
			if(Right[i+1]>Start)
			{
				Right[i]=Right[i+1];
			}
			else
			{
				Right[i]=Start;
			}
		}
		max=INT_MIN;
		for( i = 1 ; i <= n ; i++ )
		{
		
			if(max<Right[i+1] + Lift[i])
			{
				max=Right[i+1] + Lift[i];
			}
			
		}
		printf("%d\n", max);
	}
	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