#include <bits/stdc++.h>
//10:50
using namespace std;
vector<int> st;
stack<int> maxn;
void get(int sign)
{
if(sign==1){
if(!st.empty()){
st.pop_back();
maxn.pop();
}
else return;
}
else if(sign==0){
int hard;
cin>>hard;
if(maxn.empty()) maxn.push(hard);
else if(hard>maxn.top())
maxn.push(hard);
else maxn.push(maxn.top());
st.push_back(hard);
}
else{
//hardest.assign(st.begin(),st.end());
if(!st.empty()){
//sort(hardest.begin(),hardest.end(),cmp);
//int Max=*max_element(st.begin(),st.end());
cout<<maxn.top()<<endl;
}
else cout<<0<<endl;
}
}
int main()
{
int N;
cin>>N;
for(int i=0;i<N;i++){
int tmp;
cin>>tmp;
get(tmp);
}
return 0;
}
EOJ_1019_题库整理
最新推荐文章于 2023-07-16 20:46:29 发布