Cod sursa(job #1608502)

Utilizator eu3neuomManghiuc Teodor-Florin eu3neuom Data 22 februarie 2016 09:46:42
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.67 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("heapuri.in");
ofstream fout("heapuri.out");

const int NMax = 2e5 + 5;

int Pos[NMax];

set < int > Set;

int main(){
    int n, c, x, k;
    set < int > ::iterator it;
    fin >> n;
    k = 0;
    while(n--){
        fin >> c;
        if(c == 1){
            fin >> x;
            Pos[++k] = x;
            Set.insert(x);
        } else {
            if(c == 2){
                fin >> x;
                it = Set.find(Pos[x]);
                if(it != Set.end()) Set.erase(it);
            } else {
                fout << *Set.begin() << "\n";
            }
        }
    }
    return 0;
}