hdu1509

http://acm.hdu.edu.cn/showproblem.php?pid=1509

#include<iostream>
#include<queue>
using namespace std;
struct ss
{
	friend operator<(const ss a,const ss b)
	{
		if(a.v>b.v)
			return 1;
		else
			if(a.v==b.v&&a.num>b.num)
				return 1;
			else
				return 0;
	}
	int num,v,sum;
	char s[50];
};
int main()
{
	char str[5];
	int j=0;
	ss t;
	priority_queue<ss>Q;
	while(scanf("%s",str)>0)
	{
		if(str[0]=='P')
		{
			j++;
			scanf("%s%d%d%d",t.s,&t.sum,&t.v);
			t.num=j;
			Q.push(t);
		}
		else
		{
			if(Q.empty())
			{
				printf("EMPTY QUEUE!\n");
			}
			else
			{
				printf("%s %d\n",Q.top().s,Q.top().sum);
				Q.pop();
			}
		}
	}
	return 0;
}

 

posted @ 2012-12-02 16:09  紫忆  阅读(293)  评论(0编辑  收藏  举报