https://pintia.cn/problem-sets/15/problems/841
#include<bits/stdc++.h>
#define LL long long
#define GG int
#define For(i, j, k) for(int i=j; i<=k; i++)
#define Dow(i, j, k) for(int i=j; i>=k; i--)
using namespace std;
const int N = 1011;
const int INF = 0x3f3f3f3f;
const int maxn = 10000 + 10;
int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
int n;
map<int,string>mp;
int main()
{
scanf("%d",&n);
getchar();
string tmp;
priority_queue<int,vector<int>,greater<int> >que;
for(int i = 0;i < n;i++)
{
char str[30],s[30];
int num;
scanf("%s",str);
if(str[0] == 'P')
{
scanf("%s %d",s,&num);
tmp = s;
mp[num] = tmp;
que.push(num);
}
else
{
if(!que.empty())
{
int ans = que.top();
que.pop();
const char *p = mp[ans].c_str();
printf("%s\n",p);
}
else
{
printf("EMPTY QUEUE!\n");
}
}
}
return 0;
}