站外题求助
  • 板块题目总版
  • 楼主sina_malfoy
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/11/8 21:47
  • 上次更新2023/11/9 08:35:26
查看原帖
站外题求助
992714
sina_malfoy楼主2023/11/8 21:47

一本通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?

2023/11/8 21:47
加载中...