83分求调
查看原帖
83分求调
1067425
yuanyuan_a12345678楼主2024/8/3 14:43
#include<bits/stdc++.h>
using namespace std;
int main()
{
	set<int,greater<int> > s;
	stack<int> st;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x==0)
		{
			int y;
			cin>>y;
			st.push(y);
			s.insert(y); 
		}
		else if(x==1)
		{
			if(st.size()!=0) 
			{
				int y=st.top();
				s.erase(y);
				st.pop();
			}
		}
		else
		{
			if(!s.empty()) cout<<*s.begin()<<endl;
			else cout<<0;
		}
	}
	return 0;
}
2024/8/3 14:43
加载中...