• + 0 comments
    #include <bits/stdc++.h>
    #define lli long long int
    using namespace std;
    
    struct greaters {
        bool operator() (const long&a, const long&b) const {
            return a > b;
        }
    };
    
    int main (int argc, char *argv[]) {
    
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
    
        vector<int> v;
    
        lli tc;
        cin >> tc;
        while(tc--) {
            lli x;
            cin >> x;
            if (x == 1) {
                // insert
                lli val;
                cin >> val;
                v.push_back(val);
                push_heap(v.begin(), v.end(), greaters());
            } else if (x == 2) {
                // delete specific node
                lli val;
                cin >> val;
                auto it = find(v.begin(), v.end(), val);
                bool isFound = it != v.end();
                if (isFound) {
                    swap(*it, v.back());
                    v.pop_back();
                    make_heap(v.begin(), v.end(), greaters());
                }
            } else {
                // print minimum heap
                cout << v.front() << "\n";
            }
        }
        
    
        return 0;
    }