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:已经这么简单的程序应该怎么改进,才能不超时? Posted by:00348264 at 2005-01-15 18:11:51 #include <cstdio> #include <algorithm> using namespace std; int main() { int n,m; scanf("%d%d",&n,&m); long *a=new long[n],*p=a; while(n--)scanf("%d",p++); while(m--) { int i,j,k; scanf("%d%d%d",&i,&j,&k); int N=j-i+1; long *b=new long[N],*q=b; p=a+i-1; while(N--)*(q++)=*(p++); sort(b,q); printf("%d\n",*(b+k-1)); delete []b; } delete []a; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator