You are viewing a single comment's thread. Return to all comments →
This passes all the tests
#include <iostream> #include <algorithm> #include <stack> #include <vector> using namespace std; int main() { stack<int> s; int n,j,k; cin >> n; while(n--) { cin >> j; if(j == 1) { cin >> k; s.push(max(k, s.size()>0?s.top():k)); } else if(j == 2) s.pop(); else if(j == 3) cout << s.top() << '\n'; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
This passes all the tests