Cod sursa(job #539506)

Utilizator Rares95Rares Arnautu Rares95 Data 22 februarie 2011 23:16:58
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
# include <cstdio>
# include <set>
  using namespace std;
  int poz[300001], m, n, tip, x;
	multiset <int> rares;
	int main ()
	{	freopen("heapuri.in","r",stdin); freopen("heapuri.out","w",stdout);
		scanf ("%d", &n);
		for (; n; --n) 
		{	scanf ("%d", &tip);
			if (tip < 3) scanf ("%d", &x);
			if (tip == 1) {rares.insert(x); poz[++m] = x;} 
			else if (tip == 2) rares.erase (rares.find (poz[x]));
						else printf ("%d\n", *rares.begin());
		}
		return 0;
	}