运行错误求助
查看原帖
运行错误求助
593492
_wronganswer_楼主2024/8/7 20:35
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
stack<int>q;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>x;
		if(x==0){
			cin>>y;
			if(y>q.top()||q.empty())q.push(y);
			else q.push(q.top());
		}
		else
		if(x==1)if(!q.empty())q.pop();
		else{
			if(q.empty())cout<<"0\n";
			else cout<<q.top()<<"\n";
		}
	}
}
2024/8/7 20:35
加载中...