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 |
请教WA在哪里?#include<stdio.h> long l[100000],r[100000],a[100000]; void main() { long n,i,max; while(1) { scanf("%d",&n); if(n==0) return; for(i=0;i<n;i++) scanf("%d",&a[i]); l[0]=a[0]; for(i=1;i<n;i++) l[i]=l[i-1]>0?l[i-1]+a[i]:a[i]; r[n-1]=a[n-1]; for(i=n-2;i>=0;i--) r[i]=r[i+1]>0?r[i+1]+a[i]:a[i]; for(i=1;i<n;i++) l[i]=l[i]>l[i-1]?l[i]:l[i-1]; for(i=n-2;i>=0;i--) r[i]=r[i]<l[i+1]?r[i]:r[i+1]; max=l[0]+r[1]; for(i=1;i<n-1;i++) max=max>l[i]+r[i+1]?max:l[i]+r[i+1]; printf("%ld\n",max); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator