标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4120 Accepted Submission(s): 1620
#include<iostream> #include<cstring> #include<cstdio> #include<queue> using namespace std; struct node { friend bool operator<(node n1,node n2) { if(n1.priority==n2.priority) return n1.id>n2.id; else return n1.priority>n2.priority; } int id; int priority; int value; char s[50]; }; int main() { char t[4]; int k=1;; int x,y; priority_queue<node>q; struct node p; while(~scanf("%s",t)) { if(t[0]==‘P‘) { scanf("%s%d%d",p.s,&p.value,&p.priority); p.id=k++; q.push(p); } else { if(t[0]==‘G‘) { if(!q.empty()) { p=q.top(); printf("%s %d\n",p.s,p.value); q.pop(); } else cout<<"EMPTY QUEUE!"<<endl; } } } return 0; }
HDU-1509 Windows Message Queue
标签:
原文地址:http://www.cnblogs.com/cancangood/p/4426375.html