| ||||||||||
| 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:7s=1年.In Reply To:7s=1年. Posted by:liuyuquan100 at 2009-01-03 14:48:55 超时啦,附我的代码
#include "stdio.h"
#include "stdlib.h"
struct data{
int index,d;
}num[100010];
int compare(const void *a,const void *b){
struct data f=*(struct data *)a;
struct data s=*(struct data *)b;
return f.d-s.d;
}
int n,m;
int main(){
int i,j,p,t,k;
while(scanf("%d%d",&n,&m)!=EOF){
for(i=1;i<=n;i++){
scanf("%d",&num[i].d);
num[i].index=i;
}
qsort(num+1,n,sizeof(num[0]),compare);
for(t=1;t<=m;t++){
scanf("%d%d%d",&i,&j,&k);
for(p=1;p<=n;p++) {
if(num[p].index>=i&&num[p].index<=j) k--;
if(k==0) break;
}
printf("%d\n",num[p].d);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator