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

试试多次二分取位 这题方法挺多的

Posted by ACM06060 at 2007-11-06 16:00:01 and last updated at 2007-11-06 16:00:30
In Reply To:晕 怎么又是tle.. frkstyc您是怎么写的? Posted by:qiqilrq at 2007-11-06 15:49:07
> #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:
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