J - 看病要排队
#include<iostream>
using namespace std;#include<queue>
#include<string>
struct node{
int pri,id;
node(int pri,int id){
this->pri=pri;
this->id=id;
}
node(){
}
bool operator<(const node nx)const{
if(pri==nx.pri) return id>nx.id;
return pri<nx.pri;
}
};
int main(){
int n;
while(cin>>n){
priority_queue<node>doctor[4];
int id=1;
string temp;
int a,b;
while(n--){
cin>>temp;
if(temp=="IN")
{
cin>>a>>b;
node person(b,id++);
doctor[a].push(person);
}
else if(temp=="OUT"){
cin>>a;
if(doctor[a].empty())
cout<<"EMPTY"<<endl;
else {
node people=doctor[a].top();
doctor[a].pop();
cout<<people.id<<endl;
}
}
}
}
}