4 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=100010; int q[N]; int main() { int n; cin>>n; int hh=0,tt=-1; for(int i=1;i<=n;i++) { string s; cin>>s; if(s=="push") { int x; cin>>x; tt++; q[tt]=x; } else if(s=="pop") { hh++; } else if(s=="empty") { if(hh<=tt) { cout<<"NO"<<endl; } else{ //空 cout<<"YES"<<endl; } } else { cout<<q[hh]<<endl; } } return 0; }
Information
- ID
- 162
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 95
- Accepted
- 26
- Uploaded By