ybt1371求助
  • 板块学术版
  • 楼主wanwang
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/6/15 19:21
  • 上次更新2023/10/23 13:05:43
查看原帖
ybt1371求助
730717
wanwang楼主2023/6/15 19:21

ybt你别太荒谬,tmSTL优先队列我本来就比较five,但是™凹了两个半小时的模拟题都tm能超时,然后还是只超1ms,无语死了,C。

这是题目

#include<bits/stdc++.h>
using namespace std;
int n;
string op;
struct node{
	string name;
	int p;
}s;
priority_queue<node,vector<node>,less<node> >q;
bool operator<(const node &a,const node &b){
	return a.p<b.p;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>op;
		if(op=="pop"){
			if(q.empty()){
				cout<<"none\n";
				continue;
			}
			cout<<q.top().name<<" "<<q.top().p<<"\n";
			q.pop();
		}
		else{
			cin>>s.name>>s.p;
			q.push(node{s.name,s.p});
		}
	}
}
//这些是代码

求大佬

2023/6/15 19:21
加载中...