Submission #396455

# Submission time Handle Problem Language Result Execution time Memory
396455 2021-04-30T01:29:13 Z KoD Kitchen (BOI19_kitchen) C++17
31 / 100
3 ms 300 KB
#include <bits/stdc++.h>

template <class T>
using Vec = std::vector<T>;

constexpr int INF = std::numeric_limits<int>::max() / 2;

int main() {
    int N, M, K;
    std::cin >> N >> M >> K;
    Vec<int> A(N), B(M);
    for (auto& x: A) {
        std::cin >> x;
    }
    for (auto& x: B) {
        std::cin >> x;
    }
    if (std::any_of(A.begin(), A.end(), [&](const int x) { return x < K; })) {
        std::cout << "Impossible\n";
        return 0;
    }
    const int whole = std::accumulate(A.begin(), A.end(), 0);
    int ans = INF;
    for (int set = 0; set < (1 << M); ++set) {
        int crit = N * K, sum = 0;
        for (int i = 0; i < M; ++i) {
            if (set >> i & 1) {
                crit -= std::min(B[i], N);
                sum += B[i];
            }
        }
        if (crit <= 0 and sum >= whole) {
            ans = std::min(ans, sum - whole);
        }
    }
    if (ans == INF) {
        std::cout << "Impossible\n";
    }
    else {
        std::cout << ans << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 3 ms 204 KB Output is correct
10 Correct 3 ms 204 KB Output is correct
11 Correct 3 ms 204 KB Output is correct
12 Correct 3 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 3 ms 204 KB Output is correct
10 Correct 3 ms 204 KB Output is correct
11 Correct 3 ms 204 KB Output is correct
12 Correct 3 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Incorrect 1 ms 204 KB Output isn't correct
15 Halted 0 ms 0 KB -