Pagini recente » Cod sursa (job #1826967) | Cod sursa (job #654441) | Cod sursa (job #804140) | Cod sursa (job #3138568) | Cod sursa (job #2747487)
#include <iostream>
#include <set>
#include <vector>
#include <fstream>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
set<int> heap;
vector <int> pos;
int N, i, op, x, idx;
int main()
{
f >> N;
pos.assign(200001, 0);
for (i = 0; i < N; i++)
{
f >> op;
if (op == 1)
{
f >> x;
heap.insert(x);
pos[++idx] = x;
}
else if (op == 2)
{
f >> x;
heap.erase(pos[x]);
}
else if (op == 3)
{
g << *heap.begin() << endl;
}
}
}