hdu 4557

#include<stdio.h>
#include<queue>
#include<iostream>
#define N 1100
using namespace std;
struct node {
char s[20];
int  power,num;
friend bool operator<(node a,node b) {
if(a.power!=b.power)
        return  a.power>b.power;
return a.num>b.num;
}
};
int main() {
int t,n,m,i,j,k,count=0,h,flag;
char str[20];
scanf("%d",&t);
while(t--) {
scanf("%d",&n);
priority_queue<node>q,q1;
node p;k=0;h=0;
printf("Case #%d: ",++count);
while(n--) {
scanf("%s",str);
if(str[0]=='A') {
scanf("%s%d",str,&m);
 strcpy(p.s,str);
 p.power=m;
 p.num=++k;
 h++;
 q.push(p);
 printf("%d ",h);
}
else
if(str[0]=='F') {
flag=0;
scanf("%d",&m);
while(!q.empty()) {
p=q.top();
if(p.power>=m) {
printf("%s ",p.s);
flag=1;
h--;
q.pop();
break;
}
q.pop();
q1.push(p);
}
if(flag==0) 
printf("WAIT... ");
while(!q1.empty()) {
q.push(q1.top());
q1.pop();
}
}
}
}
return 0;
}




原文地址:https://www.cnblogs.com/thefirstfeeling/p/4410943.html