题目在这里
这是我的代码
#include <bits/stdc++.h>
using namespace std;
struct node{
string e;
int c;
friend bool operator<(node x,node y){
if(x.c==y.c) return x.e>y.e;
return x.c<y.c;
}
};
priority_queue<node> q;
int main()
{
int n,m,i,j,k;
int b;
string x,a;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>x;
if(x=="push")
{
cin>>a>>b;
node d={a,b};
q.push(d);
}
if(x=="pop"&&q.size())
{
cout<<q.top().e<<" "<<q.top().c;
cout<<endl;
q.pop();
}
else if(x=="pop"&&!q.size()) cout<<"none"<<endl;
}
return 0;
}
求大佬帮忙