Submission #956300

#TimeUsernameProblemLanguageResultExecution timeMemory
956300AriadnaBaloni (COCI15_baloni)C++14
100 / 100
181 ms14372 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];

    unordered_map<int, int> m;
    m.reserve(n);
    int arrows = 0;
    for (int i = 0; i < n; ++i) {
        ++m[h[i]];
        if (m[h[i]+1] > 0) {
            --m[h[i]+1];
            continue;
        }
        ++arrows;
    }
    cout << arrows << '\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...