//优先队列
#include<iostream>
#include<string>
#include<queue>
using namespace std;
struct node
{
int num, id;//num优先级,id编号
friend bool operator < (node x, node y)
{
if(x.num == y.num)
return x.id > y.id;
else
return x.num < y.num;
}
};
int main()
{
int n, temp, a, b;
node now;
while(scanf("%d", &n) != EOF )
{
priority_queue<node>q[4];
temp = 0;
while(n--)
{
char c[5];
scanf("%s", c);
if(!strcmp(c, "OUT"))
{
scanf("%d", &a);
if(q[a].empty()) printf("EMPTY\n");
else
{
now = q[a].top(); //顶端赋值给now
q[a].pop();//清空输出过得
printf("%d\n", now.id);
}
}
else if(!strcmp(c, "IN"))
{
scanf("%d%d", &a, &b);
now.id = ++temp;
now.num = b;
q[a].push(now); //压进队列
}
}
}
return 0;
}
hdu 1873 看病要排队 优先队列
最新推荐文章于 2021-07-21 17:37:56 发布