| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
改改2479就可以了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator