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:好不容易过了,虽然我想的思路挺简单,只调用四次函数,但还是不熟悉,看来最好别乱修改地址In Reply To:Re:好不容易过了,虽然我想的思路挺简单,只调用四次函数,但还是不熟悉,看来最好别乱修改地址 Posted by:acmgotogether at 2006-04-18 01:20:57 > 我的程序运行时间为1015MS,就超出了15MS的时间,请你帮一下忙,把我的程序的时间减少 > #include<iostream> > using namespace std; > int max(int a,int b) > { > if(a>=b) > return a; > else > return b; > } > > int main() > { > int n;int sum1=0,sum2=0,s;int T; > cin>>T; > for(int l=1;l<=T;l++) > { > > cin>>n; > int *a=new int [n]; > for(int i=0;i<n;i++) > { > cin>>a[i]; > } > > for(int s1=0;s1<=n-2;s1++) > for(int t1=s1;t1<=n-2;t1++) > for(int s2=t1+1;s2<=n-1;s2++) > for(int t2=s2;t2<=n-1;t2++) > { > > for(int ii=s1;ii<=t1;ii++) > { > sum1+=a[ii]; > } > for(int jj=s2;jj<=t2;jj++) > { > sum2+=a[jj]; > } > > if(s1==0&&t1==0&&s2==1&&t2==1){s=sum1+sum2;sum1=0;sum2=0;} > else > {s=max(sum1+sum2,s);sum1=0;sum2=0;} > > > } > cout<<s<<endl; > } > > return 0; > } > > > > > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator