#include <iostream>//优先队列的 应用
#include <queue>
#include <string>
using namespace std;
//中间没将数据清零 一直没注意 注意要用while(cin)不要while(1)再输入 容易OTE
struct code {
int order, lv;//排队的号码 等级
friend bool operator <(code a ,code b)
{
if (a.lv == b.lv)
return a.order > b.order;//先到先得
return a.lv < b.lv;//等级高的在前
}
void print()
{
cout << order << endl;
}
};
int main()
{
priority_queue<code> q[4];//分出3个队列
struct code code1;
int n;
while (cin >> n&&n<2000)
{
string s;
int Doc, num = 1, lv;//医生 排队号码 等级
for (int i = 1; i <= 3; i++)
{
while (!q[i].empty())//清除上一次没用完的 号码
q[i].pop();
}
for (int i = 0; i < n; i++)
{
cin >> s;
if (s == "IN")
{
cin >> Doc >> lv;
code1.lv = lv;
code1.order = num;
num++;
q[Doc].push(code1);
}
else if (s == "OUT")
{
cin >> Doc;
if (!q[Doc].empty())
{
code code2 = q[Doc].top();
code2.print();
q[Doc].pop();
}
else
cout << "EMPTY" << endl;
}
}
}
return 0;
}
hdu 1873
最新推荐文章于 2021-08-06 20:00:12 发布