优先队列简单题
#include <iostream>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <queue>
#include <vector>
using namespace std;
struct node
{
int n;
int i;
friend bool operator < (node a, node b)
{
if(a.n==b.n)
return a.i>b.i;
else
return a.n<b.n;
}
};
int main()
{
int n,A,B;
node t;
int k;
char s[4];
while(scanf("%d",&n)!=EOF)
{
k=1;
priority_queue<node> Q[4];
while(n--)
{
scanf("%s",s);
if(s[0]=='I')
{
scanf("%d%d",&A,&B);
t.n=B;
t.i=k++;
Q[A].push(t);
}
else
{
scanf("%d",&A);
if(!Q[A].empty())
{
t=Q[A].top();
Q[A].pop();
printf("%d\n",t.i);
}
else
{
printf("EMPTY\n");
}
}
}
}
return 0;
}