Cod sursa(job #2814805)

Utilizator cegaxEmanuel Soto Ortega cegax Data 8 decembrie 2021 17:21:59
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.83 kb
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rall(A) A.rbegin(),A.rend()
#define pb push_back 
#define dbg(x) do {cerr << #x <<" = " << (x) << endl; } while (false)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
//cout << setprecision(12) << fixed;



int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	ifstream in;
	ofstream out;

	in.open("heapuri.in");
	out.open("heapuri.out");

	int t; in >> t;
	
	multiset<int> s;
	vi a;

	while(t--) {
		int op; in >> op;
		if(op == 1)  {
			int num; in >> num;
			a.pb(num);
			s.insert(num);
		}
		else if(op == 2) {
			int pos; in >> pos;
			pos--;
			s.erase(s.find(a[pos]));
		}
		else {
			out << *s.begin() << "\n";
		}
	}
	
	
	return 0;
}