Cod sursa(job #2374532)

Utilizator andreihagiuandreiasdasad andreihagiuandrei Data 7 martie 2019 19:11:07
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <fstream>
#include <iterator>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
#define INF 0x3f3f3f3f
int main() {
multiset<int> heap;
multiset<int> :: iterator it;
int N;
int v[200005];
int op,x;
int k=0;
fin >> N;
for(int i=0;i<N;i++) {

fin >> op;
   if (op==1) {
        fin >> x;
        v[k] = x;
        k++;
        heap.insert(x);
    }
    else if(op==2) {
        fin>>x;
        it = heap.find(v[x-1]);
        heap.erase(*it);
        
        
    }
    else if(op==3) {
         it=heap.begin();
         fout << *it << "\n";
    }

}

}