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 |
我的c 代码#include <stdio.h> void main() { int input[100001]={0}; int left[100001],right[100001]; long num,sum,i,flag,max; scanf("%d",&num); while(num!=0){ for(i=0;i<num;i++)scanf("%d",&input[i]); sum=0; flag=input[0]; for(i=0;i<num;i++){ if(sum>=0)sum+=input[i]; else sum=input[i]; if(flag<sum)flag=sum; left[i]=flag; } sum=0; flag=input[num-1]; for(i=num-1;i>=0;i--){ if(sum>=0)sum+=input[i]; else sum=input[i]; if(flag<sum)flag=sum; right[i]=flag; } max=left[0]+right[1]; for(i=0;i<num-1;i++){ if(left[i]+right[i+1]>max)max=left[i]+right[i+1]; } printf("%d\n",max); scanf("%d",&num); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator