提交记录
题目
代码(16pts)
#include<bits/stdc++.h>
using namespace std;
long long n,a;long long sum=1,tot=1,ans=-1,bigg=-1,m,b[10003][10003],k;
long long v[100003];stack<long long>s;
int main(){
cin>>n;
for(long long i=1;i<=n;i++){
cin>>m;
if(m==0){
cin>>v[tot];s.push(v[tot]);tot++;
}
if(m==1){
if(!s.empty()) {
s.pop();v[tot-1]=-2;
}
}
if(m==2){
if(s.empty()) cout<<0<<endl;
else{
int biggg=-1;
for(int i=1;i<tot;i++){
if(v[i]>biggg) biggg=v[i];
}
cout<<biggg<<endl;
}
}
}
return 0;
}