Pagini recente » Cod sursa (job #2518236) | Cod sursa (job #180378) | Cod sursa (job #778257) | Cod sursa (job #2468763) | Cod sursa (job #2746457)
#include <bits/stdc++.h>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
set<int>h; //multimea heap ului
int poz[200005]; //este ca un vector de frecventa pentru elementele din heap
int main()
{
int N, op, x, nh = 0;
f >> N;
for (int i = 1; i <= N; ++i)
{
f >> op;
if (op == 1 || op == 2) f >> x;
if (op == 1)
{
poz[++nh] = x; //formam vectorul "de frecventa"
h.insert(x);
}
else if (op == 2) h.erase(poz[x]); //stergem elementul de pe pozitia x
else g << *h.begin() << "\n";
}
return 0;
}