Cod sursa(job #580372)

Utilizator cmiNCosmin Poieana cmiN Data 13 aprilie 2011 00:12:16
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.78 kb
#include <cstdio>
#include <set>

using namespace std;

int main()
{
    freopen("heapuri.in", "rt", stdin);
    freopen("heapuri.out", "wt", stdout);
    unsigned short int op;
    unsigned long int value, nr, vec[200001], poz = 1;
    set<unsigned long int> myset;
    scanf("%lu", &nr);
    while (nr > 0) {
        scanf("%hu", &op);
        switch (op) {
        case 1:
            scanf("%lu", &value);
            myset.insert(value);
            vec[poz++] = value;
            break;
        case 2:
            scanf("%lu", &value);
            myset.erase(vec[value]);
            break;
        case 3:
            printf("%ld\n", *(myset.begin()));
            break;
        }
        nr--;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}