Pagini recente » Cod sursa (job #1102555) | Cod sursa (job #2245644) | Cod sursa (job #545252) | Cod sursa (job #1579678) | Cod sursa (job #1485863)
#include <fstream>
#include <cassert>
#include <map>
using namespace std;
ifstream fi ("heapuri.in");
ofstream fo ("heapuri.out");
ofstream flog("heapuri.log");
int N, elem;
map <int, int> Heap1;
map <int, int> Heap2;
void af() {
for(auto& it: Heap1)
flog << it.first << " : " << it.second << '\n';
flog << '\n';
for(auto& it: Heap2)
flog << it.first << " : " << it.second << '\n';
flog << '\n';
}
int main() {
for( fi >> N; N; -- N ) {
int op, param;
fi >> op;
switch(op) {
case 1: {
fi >> param;
Heap1[++ elem] = param;
Heap2[param] = elem;
break;
}
case 2: {
fi >> param;
map<int, int> :: iterator it = Heap1.find(param);
//flog << it->first << ' ' << it->second << '\n';
Heap2.erase(Heap1[param]);
Heap1.erase(it);
break;
}
case 3:
fo << Heap2.begin()->first << '\n';
}
}
fi.close();
fo.close();
return 0;
}