poj 3481 Double Queue
#include<iostream> //随时插入数据并删除最低(高)优先级的数据
#include <map>
using namespace std;
int main()
{
map<int,int> col;
map<int,int>::iterator ite;
int op,k,p;
while(scanf("%d",&op)&&op)
{
if(op==1)
{
scanf("%d%d",&k,&p);
col[p]=k;
}
else if(op==2)
{
if(col.empty())
printf("0\n");
else
{
ite=col.end();
ite--;
printf("%d\n",ite->second);
col.erase(ite);
}
}
else
{
if(col.empty())
printf("0\n");
else
{
ite=col.begin();
printf("%d\n",ite->second);
col.erase(ite);
}
}
}
return 0;
}