菜狗只会这么写
#include<bits/stdc++.h>
using namespace std;
int main() {
priority_queue<int, vector<int>, less<int> > q;
int n;
cin >> n;
while (n--) {
string s;
cin >> s;
if (s == "push") {
int x;
cin >> x;
q.push(x);
} else if (s == "top") {
if (q.size()) {
cout << q.top() << endl;
//q.pop();
}
else{
cout<<"empty"<<endl;
}
} else {
if (q.size()) {
cout << q.top() << endl;
q.pop();
}
else{
cout<<"empty"<<endl;
}
}
}
}

京公网安备 11010502036488号