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 |
这题我TLE怎么破#include<stdio.h> int main() {int T,n,a[50000],sum,i,j,k,t,max1,max2,r,q,p; scanf("%d",&T); for(i=0;i<T;i++) {scanf("%d",&n); for(j=0;j<n;j++) scanf("%d",&a[j]);sum=-10000; for(p=0;p<n;p++){max1=-10000;max2=-10000; for(r=0;r<=p;r++) {{k=0;for(q=r;q<=p;q++) {k+=a[q]; if(max1<k) max1=k;}} for(r=p+1;r<n;r++) {t=0;for(q=r;q<n;q++){t+=a[q]; if(max2<t) max2=t;}} if(sum<max1+max2) sum=max1+max2;}} printf("%d\n",sum);} return 0;} Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator