liguoguo 2024-01-29 11:09:05
#include<bits/stdc++.h> using namespace std; stackstc; int main(){ int n; cin>>n; while(n--){ char q; cin>>q; if(q=='I'){ int m; cin>>m; stc.push(m); } else{ if(stc.empty())cout<<-1<<endl; else{ cout<<stc.top()<<endl; stc.pop(); } } } }