Submission #522421

#TimeUsernameProblemLanguageResultExecution timeMemory
522421KoDPreokret (COCI18_preokret)C++17
50 / 50
1 ms344 KiB
#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 timeMemoryGrader output
Fetching results...