Cod sursa(job #1739360)

Utilizator tudorgalatanRoman Tudor tudorgalatan Data 9 august 2016 12:41:22
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.67 kb
#include <fstream>
#include <set>

using namespace std;

unsigned int N;
unsigned short int type;
unsigned int x;

set <int> a;
int v[100001];
unsigned int i, k;

int main ()
{
    ifstream fin ("heapuri.in");
    ofstream fout ("heapuri.out");
    fin >> N;
    for (i=1; i<=N; i++)
    {
        fin >> type;
        if (type == 1)
        {
            fin >> x;
            k++;
            a.insert(x);
            v[k] = x;
        }
        else if (type == 2)
        {
            fin >> x;
            a.erase(v[x]);
        }
        else
            fout << *a.begin() << '\n';
    }
    fin.close();
    fout.close();
    return 0;
}