HDU 1875
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
struct node
{
int pri;
int num;
friend bool operator<(node n1,node n2)
{
if(n1.pri==n2.pri)
return n2.num<n1.num;
else
return n1.pri<n2.pri;
}
};
int main()
{
int n;
node now;
int a,b;
char s[5];
while(scanf("%d",&n)!=EOF)
{
int tot=0;
priority_queue<node>q[4];
while(n--)
{
scanf("%s",s);
if(s[0]=='O')
{
scanf("%d",&a);
if(q[a].empty())
printf("EMPTY\n");
else
{
now=q[a].top();
q[a].pop();
printf("%d\n",now.num);
}
}
else
{
scanf("%d%d",&a,&b);
now.num=++tot;
now.pri=b;
q[a].push(now);
}
}
}
}
网友评论