Live2d Test Env

ZOJ2724 Windows Message Queue 裸queue的模拟

题目要求FIFO


#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<queue>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
struct in
{
	string name;
	int id;
	int dex;
	in(string s,int d,int x):name(s),id(d), dex(x) { };
};
bool operator < (const in a,const in b)
{
   return a.dex>b.dex;	
}
priority_queue< in > q;
int main()
{
	string S;
	int Id,Dex;
	while(cin>>S)
	{
		if(S=="GET"){
			if(q.empty()) cout<<"EMPTY QUEUE!"<<endl;
			else {
				in t=q.top();q.pop();
				cout<<t.name<<" "<<t.id<<endl;
			}
		}
		else {
			cin>>S>>Id>>Dex;
			q.push(in(S,Id,Dex));
		}
	}
	return 0;
}

posted @ 2017-09-27 21:06  nimphy  阅读(142)  评论(0编辑  收藏  举报