有点谜的题目…不知道什么叫做双队列…维护了一个map水过了
#include <map>
#include <iostream>
#include <cstdio>
#include <iterator>
using namespace std;
int main(){
int n;
map<int,int> m;
while(scanf("%d",&n),n){
switch(n){
case 1:
int ID,pri;
scanf("%d%d",&ID,&pri);
m.insert(make_pair(pri,ID));
break;
case 2:
if(m.empty()){
printf("0\n");
}
else{
map<int,int>::iterator rite;
rite = m.end();
rite--;
printf("%d\n",(*rite).second);
m.erase(rite);
}
break;
case 3:
if(m.empty()){
printf("0\n");
}
else{
map<int,int>::iterator rite;
rite = m.begin();
printf("%d\n",(*rite).second);
m.erase(rite);
}
default:
break;
}
}
return 0;
}