#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
typedef struct node
{
int b;
int t;
friend operator < (struct node a,struct node b)
{
if(a.b==b.b)
return a.t > b.t;//t下的在前面,就是先进来的在前面
else
return b.b>a.b;//b大的在前面,就是生病厉害的在前面
}
}student;
int main()
{
int n,i,k;
char str[4];
int a,b;
while(scanf("%d",&n)!=EOF)
{
getchar();
priority_queue<student>q[4];
student temp;
for(i=1,k=1;i<=n;i++)
{
scanf("%s",str);
if(strcmp(str,"IN")==0)
{
scanf("%d%d",&a,&b);
getchar();
temp.b=b;
temp.t=k++;
q[a].push(temp);
}
else
{
scanf("%d",&a);
getchar();
if(q[a].size()==0)
printf("EMPTY\n");
else
{
printf("%d\n",q[a].top().t);
q[a].pop();
}
}
}
}
return 0;
}
看病要排队
最新推荐文章于 2020-11-03 11:39:59 发布
