WA,32分蒟蒻求助!
查看原帖
WA,32分蒟蒻求助!
1070575
xuhaoran2012f楼主2024/1/7 16:40
#include<bits/stdc++.h>
using namespace std;
stack<int>a;
stack<int>b;
int c[200000];
int main(){
	b.push(0);
	int n;
	cin>>n;
	int num=0;
	for(int i=1;i<=n;i++){
		int w;
		cin>>w;
		int k;
		if(w==0){
			cin>>k;
			a.push(k);
			if(num<a.top()){
				num=a.top();
				b.push(num);
			}
		}
		else if(w==1){
			if(a.top()==b.top()){
				b.pop();
			}
			a.pop();
		}else{
			if(a.empty()){
				cout<<0;
			}else{
				cout<<b.top()<<endl;	
			}
		}
	}
	return 0;
}

实在不会啊!

2024/1/7 16:40
加载中...