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 |
Re:WrongAnswner!!!!!为什么啊???测试数据没错啊!实在找不出!哪位大虾指教下!!!!In Reply To:WrongAnswner!!!!!为什么啊???测试数据没错啊!实在找不出!哪位大虾指教下!!!! Posted by:gaoxingok99 at 2009-07-26 14:59:14 > #include<stdio.h> > #include<string.h> > > int num[50000],n; > int a[50000],b[50000]; > void maxa(){ > int max=num[1]; > int sum=num[1]; > int lt; > a[1]=max; > > for(lt=2;lt<=n;lt++){ > if(sum>0) sum+=num[lt]; > else sum=num[lt]; > if(sum>max) max=sum; > a[lt]=max; > } > } > > void maxb(){ > int max=num[n]; > int sum=num[n]; > int lt; > b[n]=max; > for(lt=n-1;lt>=1;lt--){ > if(sum>0) sum+=num[lt]; > else sum=num[lt]; > if(sum>max) max=sum; > b[lt]=max; > } > } > > void main() > { > int t,i,j,maxall; > scanf("%d",&t); > > for(j=0;j<t;j++) > { > scanf("%d",&n); > for(i=1;i<=n;i++) scanf("%d",&num[i]); > maxa(); > maxb(); > maxall=-600000000; > > for( i=1;i<=n-1;i++) > { > if((a[i]+b[i+1])>maxall) maxall=a[i]+b[i+1]; > } > > printf("%d\n",maxall); > } > } 数组开小了 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator