Cod sursa(job #2029018)

Utilizator al_k_ponyClaudiu Babin al_k_pony Data 28 septembrie 2017 23:14:42
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.91 kb
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,op,x,m[200005],k;
multiset<int>ms;

int32_t main(){_
    freopen("heapuri.in","r",stdin);
    freopen("heapuri.out","w",stdout);
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> op;
        if(op == 1)
        {
            cin >> x;
            m[++k] = x;
            ms.insert(x);
        }
        else if(op == 2)
        {
            cin >> x;
            ms.erase(ms.find(m[x]));
        }
        else
        {
            cout << *ms.begin() << '\n';
        }
    }
}