标签:des style http color java os strong io
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <malloc.h>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <map>
using namespace std;
struct node{
char name[100];
int value;
int pri;
int id;
friend bool operator < (node a,node b){//在优先队列中,优先级高的先出列
if(a.pri == b.pri){//可以理解为在优先队列中的排序方式
return a.id > b.id;
}
return a.pri > b.pri;
}
};
int main(){
char a[100];
int k = 0;
priority_queue<node>q;
struct node p;
while(~scanf("%s",a)){
if(a[0] == 'G'){
if(!q.empty()){
p = q.top();
q.pop();
printf("%s %d\n",p.name,p.value);
//q.pop();
}
else{
printf("EMPTY QUEUE!\n");
}
}
else{
scanf("%s%d%d",p.name,&p.value,&p.pri);
p.id=k++;
q.push(p);
}
}
return 0;
}
原题http://acm.hdu.edu.cn/showproblem.php?pid=1509
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3467 Accepted Submission(s): 1391
GET PUT msg1 10 5 PUT msg2 10 4 GET GET GET
EMPTY QUEUE! msg2 10 msg1 10 EMPTY QUEUE!
标签:des style http color java os strong io
原文地址:http://blog.csdn.net/zcr_7/article/details/38355417