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

改改2479就可以了

Posted by Emember at 2009-03-12 14:33:56 on Problem 2593
#include<iostream>
using namespace std;
int a[100001];
int main()
{
	int n;
	int i;
    while(cin>>n,n != 0)
    {
        for(i=0;i<n;i++)
			scanf("%d",&a[i]);		
		int  max=a[0]+a[1];
		int  temp1=a[0]; 		
		int temp3=a[0];		
		int  temp2=a[0]+a[1]; 		
		for(i=2;i<n;i++)
		{    
            temp2=(temp2>temp1?temp2:temp1)+a[i];
			
            if(temp2>max)max=temp2;
            temp3=(temp3>0?temp3:0)+a[i-1];
            temp1=temp1>temp3?temp1:temp3;
		}
		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