Pagini recente » Cod sursa (job #1032639) | Cod sursa (job #239861) | Cod sursa (job #2438826) | redsnow_3 | Cod sursa (job #2263270)
#include <fstream>
#include <vector>
#include <map>
#include <functional>
int main()
{
std::ifstream fin("heapuri.in");
std::ofstream fout("heapuri.out");
int n;
std::map<int, int> m;
std::vector<int> history;
fin >> n;
for(int i = 0; i < n; i++)
{
int c;
fin >> c;
if(c == 1)
{
int x;
fin >> x;
history.push_back(x);
m[x]++;
}
else if (c == 2)
{
int x;
fin >> x;
auto it = m.find(history[x - 1]);
it->second --;
if(it->second == 0)
m.erase(it->first);
}
else if (c == 3)
{
fout << m.begin()->first << std::endl;
}
}
return 0;
}