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 |
快排7032MS水过#include <iostream> #include <algorithm> using namespace std; #define MAXN 100005 struct data { int pos,val; }; data N[MAXN]; int cmp(const void *a,const void *b) { return static_cast<const data*>(a)->val-static_cast<const data*>(b)->val; } int main() { //freopen("c:/aaa.txt","r",stdin); int i,p,a,b,k,cnt,n,m; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) { scanf("%d",&N[i].val); N[i].pos=i; } qsort(N+1,n,sizeof(N[0]),cmp); for(i=1;i<=m;i++) { scanf("%d%d%d",&a,&b,&k); cnt=0; for(p=1;p<=n;p++) if(a<=N[p].pos&&N[p].pos<=b) { cnt++; if(cnt==k) break; } printf("%d\n",N[p].val); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator