Submission #1106527

# Submission time Handle Problem Language Result Execution time Memory
1106527 2024-10-30T14:38:35 Z cot7302 Kitchen (BOI19_kitchen) C++17
0 / 100
14 ms 592 KB
#include <bits/stdc++.h>
#define ALL(X) begin(X), end(X)
using namespace std;
using i64 = long long;

template <class T>
using vec = vector<T>;

template <class T>
istream& operator>>(istream& is, vec<T>& V) {
    for (auto& x : V) is >> x;
    return is;
}

constexpr int inf = 1'000'000'000;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m, k; cin >> n >> m >> k;
    if (m < k) return cout << "Impossible\n", 0;
    int sum_a{};
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x < k) return cout << "Impossible\n", 0;
        sum_a += x;
    }
    vec<int> b(m);
    cin >> b;
    int sum_b = reduce(ALL(b));
    vec<int> dp(sum_b + 1, -inf);
    dp[sum_b] = 0;
    for (auto x : b) {
        for (int w = 0; w + x <= sum_b; w++)
            dp[w] = max(dp[w], dp[w + x] + min(x, n));
    }
    for (int i = sum_a; i <= sum_b; i++)
        if (dp[sum_b - i] >= n * k)
            return cout << sum_b - sum_a << '\n', 0;
    cout << "Impossible\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -