hdu 1873

#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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值