优先队列水题,真心不懂那个<号到底要怎么重载
code:
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
struct Win
{
char name[50];
int id,val,parameter;
friend bool operator < (Win a,Win b)
{
if(a.val==b.val)
{
return b.id<a.id;
}
return b.val<a.val;
}
}tmp;
priority_queue<Win> q;
int main()
{
char str[5];
int k=0;
while(~scanf("%s",str))
{
if(str[0]=='G')
{
if(q.empty())
{
puts("EMPTY QUEUE!");
}else{
tmp=q.top();
q.pop();
printf("%s %d\n",tmp.name,tmp.parameter);
}
}else{
scanf("%s%d%d",tmp.name,&tmp.parameter,&tmp.val);
tmp.id=++k;
q.push(tmp);
}
}
return 0;
}