错了???
查看原帖
错了???
1372344
ZJY1207楼主2025/1/13 16:32
#include<bits/stdc++.h>
using namespace std;
stack<int>a;
stack<int>b;
int n;
int c;
int d;
int max1=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c;
		if(c==0){
			cin>>d;
			if(d>=max1){
				max1=d;
			}
			b.push(max1);
			a.push(d);
		} else if(c==1){
			if(a.empty()){
				continue;
			} else{
				a.pop();
				b.pop();
			}
		} else{
			if(a.empty()){
				cout<<0<<endl;
			} else{
				cout<<b.top()<<endl;
			}
		}
	}
	return 0;
}

为什么?

2025/1/13 16:32
加载中...