Cod sursa(job #1068618)

Utilizator gabriel.badeaGabriel Badea gabriel.badea Data 28 decembrie 2013 15:38:58
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.63 kb
#include <algorithm>
#include <set>
#include <fstream>
using namespace std;

#define NMAX 200099

set<int> my_set;
int poz, aux_set[NMAX];

int N;

ifstream f("heapuri.in");
ofstream g("heapuri.out");

int main()
{

	f >> N;

	for(int i = 1; i <= N; ++i)
	{
		int op;
		f >> op;
		if(op == 1)
		{
			int x;
			f >> x;
			my_set.insert(x);
			aux_set[++poz] = x;
		}
		else if(op == 2)
		{
			int x;
			f >> x;
			my_set.erase(aux_set[x]);
		}
		else
		{
			set <int>::iterator it = my_set.begin();
			g << *it << endl;
		}
	}
	f.close();
	g.close();

	return 0;
}