Cod sursa(job #2450667)

Utilizator bogdanvladmihaiBogdan Vlad-Mihai bogdanvladmihai Data 24 august 2019 02:04:33
Problema Heapuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.07 kb
#include <bits/stdc++.h>

using namespace std;

const int N_MAX = 200005;
const int buffer = 1000000;

int N;
int len;

int Array[N_MAX];
char buff[buffer];

int pos = -1;

set < int > Set;

void readBuffer() {
    fread(buff, sizeof(char), buffer, stdin);
}

char readChar() {
    ++pos;
    if (pos == buffer) {
        readBuffer();
        pos = 0;
    }
    return buff[pos];
}

int readInt() {
    char c;
    int ans = 0;
    while (!isdigit(c = readChar())) ;
    while (isdigit(c)) {
        ans = 10 * ans + (c - '0');
        c = readChar();
    }
    return ans;
}

int main() {
    freopen("heapuri.in", "r", stdin);
    freopen("heapuri.out", "w", stdout);
    cin >> N;
    while (N--) {
        int t, x;
        t = readInt();
        if (t == 1) {
            x = readInt();
            Set.insert(x);
            Array[++len] = x;
        } else if (t == 2) {
            x = readInt();
            Set.erase(Array[x]);
        } else {
            cout << * Set.begin() << "\n";
        }
    }
    return 0;
}