Submission #1106528

# Submission time Handle Problem Language Result Execution time Memory
1106528 2024-10-30T14:42:13 Z cot7302 Kitchen (BOI19_kitchen) C++17
100 / 100
17 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 << i - sum_a << '\n', 0;
    cout << "Impossible\n";
}
# 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 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 428 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
# 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 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 428 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 592 KB Output is correct
2 Correct 9 ms 592 KB Output is correct
3 Correct 11 ms 592 KB Output is correct
4 Correct 16 ms 592 KB Output is correct
5 Correct 17 ms 592 KB Output is correct
6 Correct 8 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# 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 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 428 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 11 ms 592 KB Output is correct
15 Correct 9 ms 592 KB Output is correct
16 Correct 11 ms 592 KB Output is correct
17 Correct 16 ms 592 KB Output is correct
18 Correct 17 ms 592 KB Output is correct
19 Correct 8 ms 592 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 8 ms 592 KB Output is correct
26 Correct 11 ms 592 KB Output is correct
27 Correct 4 ms 336 KB Output is correct
28 Correct 8 ms 592 KB Output is correct
29 Correct 11 ms 592 KB Output is correct
30 Correct 16 ms 592 KB Output is correct