Submission #1112456

# Submission time Handle Problem Language Result Execution time Memory
1112456 2024-11-14T08:19:57 Z vjudge1 Baloni (COCI15_baloni) C++17
100 / 100
120 ms 3896 KB
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

int Phsics(int n, const vector<int>& arrows) {
    unordered_map<int, int> count;
    int arrows_needed = 0;
    for (int arrow : arrows) {
        if (count[arrow] > 0) {
            count[arrow]--;
            count[arrow - 1]++;
        } else {
            arrows_needed++;
            count[arrow - 1]++;
        }
    }

    return arrows_needed;
}

int main() {
    int n;
    cin >> n;
    vector<int> arrows(n);
    for (int i = 0; i < n; i++) {
        cin >> arrows[i];
    }
    cout << Phsics(n, arrows) << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 117 ms 3408 KB Output is correct
6 Correct 120 ms 3896 KB Output is correct
7 Correct 99 ms 3288 KB Output is correct
8 Correct 99 ms 3260 KB Output is correct
9 Correct 116 ms 3656 KB Output is correct
10 Correct 115 ms 3408 KB Output is correct