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<cstdio> #include<map> using namespace std; int q[100002]; map<int, bool> p; int main() { int n,m,t; scanf("%d %d",&n,&m); for(t=1;t<=n;t++) scanf("%d",&q[t]); for(t=0;t<=n;++t) p[t]=0; while(m--) { int i,j,k; scanf("%d %d %d",&i,&j,&k); int len=j-i+1; int Min=n; for(t=0;t<len;t++){ p[q[t+i]]=1; if(q[t+i]<Min) Min=q[t+i]; } int sum=0,a; for(a=Min;sum<k;++a) if(p[a]) sum++; printf("%d\n",a-1); for(t=0;t<len;t++) p[q[t+i]]=0; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator