Cod sursa(job #467771)

Utilizator dornescuvladVlad Eugen Dornescu dornescuvlad Data 30 iunie 2010 14:46:38
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include <fstream>
#include <set>

using namespace std;

const char iname[] = "heapuri.in";
const char oname[] = "heapuri.out";
const int nmax = 100006;

ifstream fin(iname);
ofstream fout(oname);

set<int> heap;
set<int>::iterator it;
int N, i, x, y, intrat[nmax], ct;


int main()
{	
	fin >> N;
	for(i = 1; i <= N; i ++)
	{
		fin >> x;
		if(x == 1)
		{
			fin >> y;
			intrat[++ct] = y;
			heap.insert(y);
		}
		if(x == 2)
		{
			fin >> y;
			heap.erase(intrat[y]);
			intrat[y] = 0;
		}
		if(x == 3)
		{
			it = heap.begin();
			fout << *it << "\n";
		}
	}
	return 0;
}