Cod sursa(job #539415)

Utilizator Rares95Rares Arnautu Rares95 Data 22 februarie 2011 22:18:17
Problema Heapuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.56 kb
# include <cstdio>
# include <set>
# define open_files_read(x,y); freopen ("heapuri.in", "rt", stdin); freopen ("heapuri.out", "wt", stdout); scanf ("%d%d", &x, &y)
  using namespace std;
  int n, x, m, tip, poz[200001];
	int main () 
	{ open_files_read(n,tip);
	  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;
	}