zoj 2724 Windows Message Queue(priority queue)

https://zoj.pintia.cn/problem-sets/91827364500/problems/91827366223

 

#include<bits/stdc++.h>
using namespace std;
struct message{
    string name;
    int value;
    int priority;
    friend bool operator < (const message a,const message b){
        return a.priority>b.priority;
    }
}tcin;
priority_queue<message> c;
string command;

int main(){
    ios::sync_with_stdio(false);
    while(cin>>command){
        if(command=="GET"){
            if(!c.empty()){
                message temp=c.top();c.pop();
                cout<<temp.name<<" "<<temp.value<<endl;
                continue;
            }
            else{
                cout<<"EMPTY QUEUE!"<<endl;
                continue;
            }
        }
        else{
            cin>>tcin.name>>tcin.value>>tcin.priority;
            c.push(tcin);
        }
    }
    return 0;
}

 

posted @ 2021-04-11 09:46  limited_Infinite  阅读(44)  评论(0编辑  收藏  举报
// //返回顶部 //返回顶部按钮