题目: https://vjudge.net/contest/220145#problem/C
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
using namespace std;
struct br{
int y;
int id;
};
struct cmp//降序排序
{
bool operator ()(br a,br b)
{
return a.y>b.y;
}
};
int main()
{
int n;
while(scanf("%d",&n)==1)
{
multiset<br,cmp> a[4];//代表3个医生的队伍
multiset<br,cmp>::iterator it;
string c;
int q,w;
br x;
int j=0;
while(n--)
{
cin >> c;
if(c=="IN")
{
j++;
cin >> w >> q;
x.y=q;x.id=j;
a[w].insert(x);//相等时,后来的排在后面(方便)
}
else
{
cin >> w;
if(a[w].size()==0){
cout << "EMPTY" << endl;
}
else
{
it=a[w].begin();//begin就是开头
cout << it->id << endl;
a[w].erase(it);//只会删掉这个元素,和它相等的不会删
}
}
}
}
return 0;
}
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
using namespace std;
struct br{
int y;
int id;
};
struct cmp//降序排序
{
bool operator ()(br a,br b)
{
return a.y>b.y;
}
};
int main()
{
int n;
while(scanf("%d",&n)==1)
{
multiset<br,cmp> a[4];//代表3个医生的队伍
multiset<br,cmp>::iterator it;
string c;
int q,w;
br x;
int j=0;
while(n--)
{
cin >> c;
if(c=="IN")
{
j++;
cin >> w >> q;
x.y=q;x.id=j;
a[w].insert(x);//相等时,后来的排在后面(方便)
}
else
{
cin >> w;
if(a[w].size()==0){
cout << "EMPTY" << endl;
}
else
{
it=a[w].begin();//begin就是开头
cout << it->id << endl;
a[w].erase(it);//只会删掉这个元素,和它相等的不会删
}
}
}
}
return 0;
}