Submission #522421

# Submission time Handle Problem Language Result Execution time Memory
522421 2022-02-05T01:05:39 Z KoD Preokret (COCI18_preokret) C++17
50 / 50
1 ms 344 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::tuple;
using std::pair;

constexpr int L = 2880;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    array<array<int, 2>, L> game = {};
    int half = 0;
    for (int k = 0; k < 2; ++k) {
        int n;
        std::cin >> n;
        while (n--) {
            int x;
            std::cin >> x;
            half += x <= L / 2;
            game[x - 1][k] += 1;
        }
    }
    std::cout << half << '\n';
    int turn = 0;
    array<int, 2> score = {};
    array<bool, 2> losing = {};
    for (const auto& add : game) {
        array<int, 2> next = score;
        for (int k = 0; k < 2; ++k) {
            next[k] += add[k];
        }
        for (int k = 0; k < 2; ++k) {
            if (losing[k] and next[k] > next[k ^ 1]) {
                turn += 1;
            }
        }
        for (int k = 0; k < 2; ++k) {
            if (next[k] > next[k ^ 1]) {
                losing[k] = false;
                losing[k ^ 1] = true;
            }
        }
        score = std::move(next);
    }
    std::cout << turn << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 332 KB Output is correct