wrongnumber 2014-08-16 01:02:45
点我顶贴
收藏
删除
伴随数组解可以ac
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
int i,j;
friend bool operator < (const struct node &aa,const struct node &bb)
{
return aa.i<bb.i;
}
}a[10002];
int n,m;
int main()
{
scanf("%d%d",&n,&m);
for (int q=1;q<=n;q++) {scanf("%d",&a[q].i);a[q].j=q;}
sort(a+1,a+n+1,less<node>());
for (int q=0,i,j,k,p;q<m;q++)
{
scanf("%d%d%d",&i,&j,&k);
for (p=1;k>0;p++)
if (a[p].j>=i && a[p].j<=j)
k--;
printf("%d\n",a[p-1].i);
}
//system("pause");
return 0;
}
之前用快排变形只能过90分 原因莫名...