7-26 Windows消息队列 (25 分)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef pair<int, string> PII;
int main(){
	priority_queue<PII, vector<PII>, greater<PII>> pq;
	string op, msg;
	int idx, n;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>op;
		if(op == "PUT"){
			cin>>msg>>idx;
			pq.push({idx, msg});
		}else{
			if(pq.empty()){
				cout<<"EMPTY QUEUE!"<<endl;
			}else{
				PII t = pq.top();
				pq.pop();
				cout<<t.second<<endl;
			}
		}
	}
	return 0;
}

你可能感兴趣的:(数据结构与算法题目集)