优先队列,但是2T 大佬求调```cpp
#include<bits/stdc++.h>
using namespace std;
struct cxk{
int zhi,wei;
bool operator < (const cxk&b) const
{
return zhi > b.zhi;
}
};
int n,k,m;
priority_queue q;
queue q1;
cxk op,ba;
int a[1000005];
int main(){
cin>>m>>n;
for(int i=1;i<=m;i++){
cin>>a[i];
q.push({a[i],i});
}
for(int k=1,x,y;k<=n;k++){
cin>>x>>y;
while(q.top().wei<x||q.top().wei>y){
q1.push(q.top());
q.pop();
}
cout<<q.top().zhi<<" ";
while(!q1.empty()){
q.push(q1.front());
q1.pop();
}
}
return 0;
}