Cod sursa(job #1823775)

Utilizator doroftei1999Doroftei Andrei doroftei1999 Data 6 decembrie 2016 20:20:30
Problema Heapuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");

int main() {
    int k;
    vector<int> v, z;
    in >> k;
    for(int i = 0; i < k; i++) {
        int x;
        in >> x;
        if(x == 1) {
            int y;
            in >> y;
            v.push_back(y);
            push_heap(v.begin(), v.end());
            z.push_back(y);
        }
        else if(x == 2) {
            int a;
            in >> a;
            v.erase(find(v.begin(), v.end(), z[a - 1]));
        }
        else
            out << v.front() << '\n';
        reverse(v.begin(), v.end());
    }
    return 0;
}