Pagini recente » Cod sursa (job #537112) | Cod sursa (job #1956166) | Cod sursa (job #342911) | Cod sursa (job #1090254) | Cod sursa (job #467771)
Cod sursa(job #467771)
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
const char iname[] = "heapuri.in";
const char oname[] = "heapuri.out";
const int nmax = 100006;
ifstream fin(iname);
ofstream fout(oname);
set<int> heap;
set<int>::iterator it;
int N, i, x, y, intrat[nmax], ct;
int main()
{
fin >> N;
for(i = 1; i <= N; i ++)
{
fin >> x;
if(x == 1)
{
fin >> y;
intrat[++ct] = y;
heap.insert(y);
}
if(x == 2)
{
fin >> y;
heap.erase(intrat[y]);
intrat[y] = 0;
}
if(x == 3)
{
it = heap.begin();
fout << *it << "\n";
}
}
return 0;
}