标签:
7 IN 1 1 IN 1 2 OUT 1 OUT 2 IN 2 1 OUT 2 OUT 1 2 IN 1 1 OUT 1
2 EMPTY 3 1 1
#include<stdio.h>
#include<queue>
#include<string.h>
using namespace std;
struct sick
{
int id;
int num;
} s;
bool operator<(const sick &x,const sick &y)
{
if(x.num!=y.num)
return x.num<y.num;
else
return x.id>y.id;
}
int main()
{
int t;
while(scanf("%d",&t)!=EOF)
{
int k=1;
priority_queue<sick>q[5];
while(t--)
{
char str[5];
int a,b;
scanf("%s%d",str,&a);
if(strcmp(str,"IN")==0)
{
scanf("%d",&b);
s.num=b;
s.id=k++;
q[a].push(s);
}
else
{
if(!q[a].empty())
{
s=q[a].top();
q[a].pop();
printf("%d\n",s.id);
}
else
printf("EMPTY\n");
}
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/bailuweishuang520/article/details/47187621