Cod sursa(job #696869)
Utilizator | Sergiu SegaXXX | Data | 28 februarie 2012 20:39:19 |
---|---|---|---|
Problema | Heapuri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.67 kb |
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
#define zz 200001
int a[zz],nr;
multiset <int> sega;
multiset <int> :: iterator it;
int main()
{
int n,k,x;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
f>>n;
for(int i=1;i<=n;i++)
{
f>>k;
if(k!=3) f>>x;
if(k==1)
{
a[++nr]=x;
sega.insert(x);
}
if(k==2)
{
sega.erase(sega.find(a[x]));
}
if(k==3)
{
it=sega.begin();
g<<*it<<'\n';
}
}
f.close();
g.close();
return 0;
}