You are viewing a single comment's thread. Return to all comments →
c++ solution. Passed all tests:
int main() { int N; cin >> N; vector <int> s; vector <int> max; max.push_back(0); while (N--) { int q; cin >> q; if (q==1) { int x; cin >> x; s.push_back(x); if ((x>=max.back())) max.push_back(x); } else if (q==2) { if (s.back()==max.back()) max.pop_back(); s.pop_back(); } else cout << max.back() << endl; } 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 →
c++ solution. Passed all tests: