标签:
题目链接:
http://acm.split.hdu.edu.cn/showproblem.php?pid=1509
Hint:
题意:
优先队列。
题解:
优先队列,水题。
代码:
#include <cstdio> #include <cstring> #include <queue> #include <iostream> #include <algorithm> using namespace std; struct node { char name[100+10]; int x,val; int time; friend bool operator <(node a,node b) { if(a.val!=b.val) return a.val>b.val; return a.time>b.time; } }s; char a[10]; int main() { int num=0; priority_queue<node>q; while(!q.empty()) q.pop(); while(scanf("%s",a)!=EOF) { if(strcmp(a,"GET")==0) { if(q.empty()) printf("EMPTY QUEUE!\n"); else { node b=q.top(); q.pop(); printf("%s %d\n",b.name,b.x); } } else { scanf("%s %d %d",s.name,&s.x,&s.val); s.time=num++; q.push(s); } } }
HDU 1509 Windows Message Queue
标签:
原文地址:http://www.cnblogs.com/TAT1122/p/5835473.html