Cod sursa(job #1623624)

Utilizator teodor440Teodor Tonghioiu teodor440 Data 1 martie 2016 20:38:54
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include <iostream>
#include <fstream>
#include <set>
using namespace std;

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

const int nmax = 200005;
set <int> heap;

int main()
{
	int n, op, x, ord[nmax], i, dim = 0;
	fin >> n;
	for (i = 1; i <= n; i++)
	{
		fin >> op;
		if (op == 1)
		{
			fin >> x;
			ord[++dim] = x;
			heap.insert(x);
		}
		else if (op == 2)
		{
			fin >> x;
			heap.erase(ord[x]);
		}
		else fout << *heap.begin() << "\n";
	}
	fin.close();
	fout.close();
	return 0;
}