Cod sursa(job #539408)

Utilizator Rares95Rares Arnautu Rares95 Data 22 februarie 2011 22:13:49
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
# include <cstdio>
# include <set>
# define open_files_read(x); freopen ("heapuri.in", "rt", stdin); freopen ("heapuri.out", "wt", stdout); scanf ("%d", &x)
  using namespace std;
  int n, x, m, tip, poz[200001];
	int main () 
	{ open_files_read(n);
	  set <int> rares;
	  set <int> :: iterator it;
		for (; n; --n)
		{	scanf ("%d", &tip);
			if (tip < 3) scanf ("%d", &x);
			if (tip == 1) {rares.insert(x); poz[++m] = x;}
			if (tip == 2) rares.erase (poz[x]);
			if (tip == 3) {it = rares.begin (); printf ("%d\n", *it);}
		}
		return 0;
	}