Submission #929160

# Submission time Handle Problem Language Result Execution time Memory
929160 2024-02-17T19:29:52 Z Karoot Baloni (COCI15_baloni) C++17
0 / 100
599 ms 131076 KB
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>

#define all(x)  (x).begin(), (x).end()
#define rall(x)  (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;

ll linf = 1e15+1;

inline void scoobydoobydoo(){
    ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}

set<int> bals[1000003];

int main(){
    scoobydoobydoo();
    int n; cin >> n;
    set<pair<int, int>> v;

    for (int i = 0; i < n; i++){
        int h; cin >> h;
        v.insert({i, h});
        bals[h].insert(i);
    }

    int sum = 0;

    while (!v.empty()){
        sum++;
        int h = (*v.begin()).second;
        int i = (*v.begin()).first;
        v.erase(v.begin());
        if (v.empty())break;
        auto it = bals[h-1].upper_bound(i);

        while (it != bals[h-1].end()){
            auto itr = v.find({*it, h-1});
            v.erase(itr);
            i = *it;
            h--;
            it = bals[h-1].upper_bound(i);
        }
    }

    cout << sum << endl;




    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 95940 KB Execution killed with signal 6
2 Runtime error 46 ms 96080 KB Execution killed with signal 6
3 Runtime error 47 ms 96592 KB Execution killed with signal 6
4 Runtime error 52 ms 96580 KB Execution killed with signal 6
5 Runtime error 566 ms 131072 KB Execution killed with signal 9
6 Runtime error 566 ms 131072 KB Execution killed with signal 9
7 Runtime error 568 ms 131076 KB Execution killed with signal 9
8 Runtime error 558 ms 131072 KB Execution killed with signal 9
9 Runtime error 599 ms 131072 KB Execution killed with signal 9
10 Runtime error 555 ms 131072 KB Execution killed with signal 9