#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
struct node
{
int d,s;
node (int a,int b):d(a),s(b){}
bool operator <(const node a) const
{
if (s!=a.s) return s<a.s;
else return d>a.d;
}
};
int main()
{
int n;
while (~scanf("%d",&n))
{
priority_queue <node> q[5];
int t=1;
while (n--)
{
char c[5];
int a,b;
getchar();
scanf("%s",&c);
if (c[0]=='I')
{
scanf("%d%d",&a,&b);
//q[a].d=t++;
//q[a].s=b;
q[a].push(node(t++,b));
}
else if (c[0]=='O')
{
scanf("%d",&a);
if (q[a].empty()) printf("EMPTY\n");
else
{
node k=q[a].top();
q[a].pop();
printf("%d\n",k.d);
}
}
}
}
return 0;
}
医院就诊队列模拟

本文介绍了一个基于优先级的医院就诊模拟系统实现。系统通过优先队列管理不同优先级病人的就诊顺序,确保紧急病人能够优先得到治疗。文章提供了完整的C++代码示例,展示了如何使用优先队列处理多种就诊事件。
912

被折叠的 条评论
为什么被折叠?



