谁能告诉我这题为什么会超时两个点?
  • 板块学术版
  • 楼主sandwich
  • 当前回复17
  • 已保存回复17
  • 发布时间2020/7/9 09:36
  • 上次更新2023/11/6 23:25:36
查看原帖
谁能告诉我这题为什么会超时两个点?
73361
sandwich楼主2020/7/9 09:36

题目在这里

这是我的代码

#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;
}

求大佬帮忙

2020/7/9 09:36
加载中...