一本通p1371
#include<bits/stdc++.h>
using namespace std;
struct node{
char name[25];int b;
bool operator<(const node a)const{
return b<a.b;
}
};
priority_queue<struct node> q;
int main(){
// ios::sync_with_stdio(false);
// cin.tie(0);
node tmp;
int n;//cin>>n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
char s[15];
// cin>>s;
scanf("%s",s);
if(strcmp(s,"push")==0){
// cin>>tmp.name>>tmp.b;
scanf("%s%d",tmp.name,&tmp.b);
q.push(tmp);
}
else{
if(q.empty())
cout<<"none"<<'/n';
else{
cout<<q.top().name<<" "<<q.top().b<<'\n';
q.pop();
}
}
}
return 0;
}
解决超时了,但是第3、4个点WA了
另外,为什么
// ios::sync_with_stdio(false);
// cin.tie(0);
这两行去掉注释就是全WA?