dev上样例过了,但洛谷上0
查看原帖
dev上样例过了,但洛谷上0
850062
zzxzczyz楼主2024/5/4 19:50
#include<bits/stdc++.h>
using namespace std;
long long n,maxx[200005],cnt;
int main(){
	cin>>n;
	while(n--){
		int opt;
		cin>>opt;
		if(opt==0){
			long long x;
			cin>>x;
			maxx[++cnt]=max(maxx[cnt-1],x);
		}
		if(opt==1&&cnt>0){
			cnt--;
		}
		if(opt==2){
			if(cnt==0){
				cout<<"0"<<endl;
			}
			else cout<<maxx[cnt]<<"\n";
		}
	}
	return 0;
}
2024/5/4 19:50
加载中...