1 solutions
-
1
#include<bits/stdc++.h> using namespace std; const int N=100010; int stk[N],tt=0; int main() { int n; cin>>n; string str; while(n--) { cin>>str; if(str=="push") { int x; cin>>x; stk[++tt]=x; } else if(str=="pop") tt--; else if(str=="query") cout<<stk[tt]<<endl; else if(str=="empty") { if(tt>0) { cout<<"NO"<<endl; } else cout<<"YES"<<endl; } } return 0; }
- 1
Information
- ID
- 169
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- # Submissions
- 61
- Accepted
- 16
- Uploaded By