Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题我TLE怎么破

Posted by 1100802111 at 2013-01-28 13:56:58 on Problem 2479
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator