Cod sursa(job #2894367)
Utilizator | Data | 27 aprilie 2022 18:53:25 | |
---|---|---|---|
Problema | Heapuri | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.71 kb |
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
set<int> h;
int main()
{ ifstream f("heapuri.in");
ofstream g("heapuri.out");
int n,x,v[200001],poz=1,y;
f>>n;
for(int i=1;i<=n;i++)
{
f>>x;
//identificam tipul operatiei
if(x==1)
{ //executam inserarea
f>>y;
h.insert(y);
v[poz]=y;
poz++;
}
else
if(x==2)
{ //executam stergerea
f>>y;
h.erase(v[y]);
}
else
if(x==3)
{ //afisam cel mai mic numar
g<<*h.begin()<<"\n";
}
}
return 0;
}