#include <bits/stdc++.h> using namespace std; struct node{ int num; int j; }; bool operator<(node x,node y){ if(x.j==y.j) return x.num>y.num; else return x.j<y.j; //小的排后面 } int main(){ ios::sync_with_stdio(false); int n; while(~scanf("%d",&n)){ priority_queue<node> s[4]; char a[5]; int x,y; int k=1; for(int i=0;i<n;i++){ scanf("%s",a); if( a[0]==‘I‘){ scanf("%d%d",&x,&y); s[x].push( node{k++,y}); }else if(a[0]==‘O‘){ scanf("%d",&x); if ( !s[x].empty()) { node now=s[x].top(); s[x].pop(); //cout<<now.num<<endl; printf("%d\n",now.num); }else { printf("EMPTY\n"); //cout<<""<<endl; } } } } return 0; }
原文:https://www.cnblogs.com/lyj1/p/11503005.html