Pagini recente » Cod sursa (job #463927) | Cod sursa (job #952943) | Cod sursa (job #502472) | Cod sursa (job #1799191) | Cod sursa (job #2263269)
#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++)
{
static std::function<void()> v[] = {
[&](){
int x;
fin >> x;
history.push_back(x);
m[x]++;
},
[&](){
int x;
fin >> x;
auto it = m.find(history[x - 1]);
it->second --;
if(it->second == 0)
m.erase(it->first);
},
[&](){
fout << m.begin()->first << std::endl;
},
};
int c;
fin >> c;
v[c - 1]();
}
return 0;
}