49分求助!!!
查看原帖
49分求助!!!
612152
lijuncheng_1207楼主2023/5/28 17:46
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
int n,c,x;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>c;
		if(c==0){
			cin>>x;
			a.push_back(x);
		}
		else if(c==1&&!a.empty()){
			a.pop_back();
		}
		else if(c==2){
			if(!a.empty()){
				cout<<*max_element(a.begin(),a.end())<<endl;
			}
			else if(a.empty()){
				cout<<0<<endl;
			}
		}
	}
	return 0;
}
多多指教
2023/5/28 17:46
加载中...