| ||||||||||
| 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.. frkstyc您是怎么写的?In Reply To:Sempr用的是n多个二分的方法,我看明白了也写不出来... Posted by:qiqilrq at 2007-11-06 15:34:00 #include <stdio.h>
#include <stdlib.h>
#define maxn 101000
int dat[maxn];
int idx[maxn];
int n,si,ti,k;
int cmp(const void *p,const void *q){
int a=*(int*)p;
int b=*(int*)q;
return dat[a]-dat[b];
}
int main(){
int i,j,q,cnt;
scanf("%d%d",&n,&q);
for(i=0;i<n;i++)scanf("%d",dat+i),idx[i]=i;
qsort(idx,n,4,cmp);
for(i=q;i;i--){
cnt=0;
scanf("%d%d%d",&si,&ti,&k);si--;ti--;
for(j=0;j<n;j++)
if(idx[j]>=si&&idx[j]<=ti){
cnt++;if(cnt==k){
printf("%d\n",dat[idx[j]]);
break;
}
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator