Submission #1033247

# Submission time Handle Problem Language Result Execution time Memory
1033247 2024-07-24T14:56:31 Z phoenix Kitchen (BOI19_kitchen) C++17
0 / 100
40 ms 3932 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 333;

int n, m, k;

int A[N];
int B[N];


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        cin >> A[i];
    for (int i = 0; i < m; i++)
        cin >> B[i];
    
    if (*min_element(A, A + n) < k) {
        cout << "Impossible\n";
        return 0;
    }

    sort(B, B + m);

    int sum = 0;
    for (int i = 0; i < m; i++) sum += B[i];

    vector<vector<int>> dp(sum + 1, vector<int>(k + 1, 0));
    dp[0][0] = 1e9;
    for (int i = 0; i < m; i++) {
        for (int s = sum; s >= B[i]; s--) {
            for (int j = 1; j <= k; j++) {
                dp[s][j] = max(dp[s][j], min(s / j, dp[s - B[i]][j - 1]));
            }
        }
    }
    int x = 0;
    for (int i = 0; i < n; i++) x += A[i];
    for (int i = x; i <= sum; i++) {
        if (dp[i][k] >= n) {
            cout << i - x << '\n';
            return 0;
        }
    }
    cout << "Impossible\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 604 KB Output is correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -