#include <iostream> #include <cstdio> #include <stack> using namespace std; int main() { stack<int> st,st_min; int n,x; char s[2]; while(scanf("%d",&n)!=EOF) { for(int i=0; i<n; i++) { scanf("%s",&s); if(s[0]=='s') { scanf("%d",&x); st.push(x); if(!st_min.empty()) { int t=st_min.top(); if(x<t) { st_min.push(x); } } else { st_min.push(x); } printf("%d ",st_min.top()); } else { if(!st.empty()) { int t=st.top(); st.pop(); if(t==st_min.top()) { st_min.pop(); } } if(!st_min.empty()) { printf("%d ",st_min.top()); } else { printf("NULL "); } } } } return 0; } /************************************************************** Problem: 1522 User: jasonhaven Language: C++ Result: Accepted Time:20 ms Memory:1524 kb ****************************************************************/