Cod sursa(job #1068575)

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

#define NMAX 200001

int main()
{
	set<int> my_set;
	int aux_set[NMAX];
	int poz = 1;

	int N, op, x;

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

	f >> N;

	for(int i = 0; i < N; ++i)
	{
		f >> op;
		if(op == 1)
		{
			f >> x;
			my_set.insert(x);
			aux_set[poz++] = x;
		}
		else if(op == 2)
		{
			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;
}