| ||||||||||
| 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 | |||||||||
why re#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
int z,d[110001],a[110001];
void quickSort(int l,int r)
{
if (l >= r || z<=0) return;
int i = l,j = r + 1,pivot = d[l],tm;
while(1)
{
do {++i;} while (d[i] < pivot);
do {--j;} while (d[j] > pivot);
if (i >= j) break;
tm = d[i];
d[i] = d[j];
d[j] = tm;
}
d[l] = d[j];
d[j] = pivot;
tm = j-l;
if(tm>=z)
quickSort(l, j-1);
else
{
z -= tm+1;
quickSort(j+1, r);
}
}
void main()
{
long x,y,i,n,m;
scanf("%d%d",&n,&m);
for(i=0;i<n;++i)
scanf("%d",&a[i]);
while(m--)
{
scanf("%d%d%d",&x,&y,&z);
--x,y-=x;
memcpy(d,a+x,(y<<4));
--y;
i = z-1;
quickSort(0,y);
printf("%d\n",d[i]);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator