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; }
本文在博客园发布,作者:limited_Infinite,转载请注明原文链接:https://www.cnblogs.com/limitedInfinite/p/14643016.html