首页 > 其他 > 详细

hdu 1873 看病要排队

时间:2015-04-22 09:39:29      阅读:148      评论:0      收藏:0      [点我收藏+]

考察优先队列,以及对队列的一系列操作

#include<iostream>
#include<queue>
int n;
using namespace std;
struct stu
{
	int num,po;
	friend bool operator<(stu x,stu y)
	{
		if(x.po==y.po) return x.num>y.num;
		return x.po<y.po;
		
	}
};
priority_queue<stu>mapp[4];
string cmd;
stu d;
int main()
{
	while(cin>>n)
	{
		for(int i=0;i<4;i++)
		{
			while(mapp[i].size()) mapp[i].pop();
		}
		int t=1;
		for(int i=1;i<=n;i++)
		{
			cin>>cmd;
			if(cmd=="IN")
			{
				int x,y;
				cin>>x>>y;
				d.num=t;d.po=y;t++;				
				mapp[x].push(d);
			}
			else
			{
				int x;
				cin>>x;
				if(mapp[x].size())
				{
					cout<<mapp[x].top().num<<endl;
					mapp[x].pop();
				}
				else
				{
					cout<<"EMPTY"<<endl;
				}
			}
		}
	}
	return 0;
} 


hdu 1873 看病要排队

原文:http://blog.csdn.net/zafkiel_nightmare/article/details/45177361

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!