#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct Message
{
string msg;
int priority;
};
struct Cmp
{
bool operator()(Message const &msg_a,Message const &msg_b)
{
return msg_a.priority>msg_b.priority;
}
};
int main()
{
priority_queue<Message,vector<Message>,Cmp> msg_queue;
int n;
cin>>n;
for(int i=0;i<n;++i)
{
string tmp;
cin>>tmp;
if(tmp=="PUT")
{
Message msg_tmp;
cin>>msg_tmp.msg>>msg_tmp.priority;
msg_queue.push(msg_tmp);
}
else
{
if(!msg_queue.empty())
{
cout<<msg_queue.top().msg<<endl;
msg_queue.pop();
}
else
{
cout<<"EMPTY QUEUE!"<<endl;
}
}
}
}
windows 消息队列
最新推荐文章于 2023-10-17 13:50:35 发布