Cod sursa(job #3131033)

Utilizator CostyRoCostin Ionescu CostyRo Data 19 mai 2023 01:31:16
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 kb
#include<iostream>
#include<fstream>
#include <set>

std::ifstream input_file("heapuri.in");
std::ofstream output_file("heapuri.out");
std::set<int>heap;

int main(){
	int history[200001];

	int n,command, number;
  input_file>>n;
	int no_elements=0;

	for(int i=1;i<=n;i++){
		input_file>>command;
		if(command==1){
			input_file>>number;
			history[++no_elements]=number;
			heap.insert(number);
		}
		else if(command==2){
				input_file>>number;
				heap.erase(history[number]);
		}
		else if(command==3){
      output_file<<*heap.begin()<<"\n";
    }
	}

	input_file.close();
	output_file.close();

	return 0;
}