16pts!
  • 板块P1165 日志分析
  • 楼主lxc129
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/5/12 12:05
  • 上次更新2024/5/12 15:40:08
查看原帖
16pts!
1126733
lxc129楼主2024/5/12 12:05
#include<bits/stdc++.h>
using namespace std;
long long op,n,x,maxx;
stack<int>s;
int main(){
	cin>>n;
	while (n--){
		cin>>op;
		if (op==0){
			cin>>x;
			if (s.size()==0) s.push(x);
			else if (x>s.top()) s.push(x);
		}
		if (op==1){
			if (s.top()==x && x!=0) s.pop();
			if (s.top()==x && x==0) cout<<"0\n";
		}
		if (op==2) cout<<s.top()<<'\n';
	}
}
2024/5/12 12:05
加载中...