Cod sursa(job #830394)

Utilizator antonioteoZait Teodor Antonio antonioteo Data 6 decembrie 2012 19:45:43
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.57 kb
#include <fstream>
#include <set>
using namespace std;
const char iname[] = "heapuri.in";
const char oname[] = "heapuri.out";
ifstream fin(iname);
ofstream fout(oname);
int N , op , x , i , nr;
int poz[ 200004 ];
set < int > H;
set < int > :: iterator it;
int main()
{
	fin >> N;
	for ( i = 1; i <= N; ++i )
	{
		fin >> op;
		if ( op == 3 )
		{
			it = H.begin();
			fout << *it << '\n';
		}
		else
		{
			fin >> x;
			if ( op == 1 )
			{
				H.insert( x );
				++nr; 
				poz[ nr ] = x;
			}
			else 
				H.erase( poz[ x ] );
		}
	}
	return 0;
}