Cod sursa(job #865168)

Utilizator cernat.catallinFMI Cernat Catalin Stefan cernat.catallin Data 26 ianuarie 2013 09:50:42
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.64 kb
#include <fstream>
#include <vector>
#include <set>
using namespace std;

ifstream f ("heapuri.in");
ofstream g ("heapuri.out");

vector <int> pozitie;
multiset <int> heap;

int n, x, y;

int main(){
    f >> n;
    pozitie.reserve(n+1);
    pozitie.push_back(0);

    for(int i = 1; i <= n; ++i){
        f >> x;
        if(x == 1){
            f >> y;
            pozitie.push_back(y);
            heap.insert(y);
        }
        if(x == 2){
        f >> y;
            heap.erase( heap.find(pozitie[y]) );
        }
        if(x == 3) g << *heap.begin() << "\n";
    }
    f.close();
    g.close();

    return 0;
}