Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:7s=1年.

Posted by runformydream at 2009-08-03 22:34:46 on Problem 2104
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator