Cod sursa(job #2898133)

Utilizator 0SiSBesliu Radu-Stefan 0SiS Data 6 mai 2022 09:31:20
Problema Heapuri Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("heapuri.in");
ofstream g("heapuri.out");

set < int > mset;
vector < int > pos;
int n, x, y;

int main() {
  f >> n;
  for (int i = 0; i < n; ++i) {
    f >> x;
    if (x == 1) {
      f >> y;
      mset.insert(y);
      pos.emplace_back(y);
    } 
    else if (x == 2) {
      f >> y;
      mset.erase(mset.find(pos[y - 1]));
    } 
    else {
      g << *mset.begin() << '\n';
    }
  }
}