Untitled

 avatar
user_9000366
plain_text
2 months ago
390 B
4
Indexable
void Mesh_JOO() {
    int q;
    cin>>q;
    stack<int>st;
    while (q--) {
        int ty;
        cin>>ty;
        if(ty==1) {
            int x;
            cin>>x;
            if (!st.empty())x=max(x,st.top());
            st.push(x);
        }else if (ty==2) {
            if (!st.empty())st.pop();
        }else {
            cout<<st.top()<<'\n';
        }
    }
}
Editor is loading...
Leave a Comment