原题链接:https://www.acwing.com/problem/content/830/
#include<iostream>
using namespace std;
const int N = 100010;
int q[N], tt;
int main()
{
int m;
scanf("%d", &m);
while(m --)
{
string a;
int x;
cin >> a;
if(a == "push")
{
scanf("%d", &x);
q[++ tt] = x;
}
else if(a == "pop") tt --;
else if(a == "empty")
{
if(tt) cout << "NO" << endl;
else cout << "YES" << endl;
}
else cout << q[tt] << endl;
}
return 0;
}