Submission #444792

# Submission time Handle Problem Language Result Execution time Memory
444792 2021-07-15T10:08:16 Z zxcvbnm Kitchen (BOI19_kitchen) C++14
0 / 100
16 ms 8740 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;
const int maxN = 45;
bool dp[maxN][maxN*maxN][maxN*maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for(int& i : a) {
        cin >> i;
    }
    for(int& i : b) {
        cin >> i;
    }

    int ans = INF;
    for(int i : a) {
        if (i < k) {
            cout << "Impossible\n";
            exit(0);
        }
    }

    int time = accumulate(a.begin(), a.end(), 0);
    dp[0][0][0] = true;
    for(int i = 1; i <= m; i++) {
        for(int j = 0; j < maxN; j++) {
            for(int p = 0; p < maxN; p++) {
                dp[i][j][p] |= dp[i-1][j][p];

                if (j-b[i-1] < 0 || p-min(n, b[i-1]) < 0) continue;
                dp[i][j][p] |= dp[i-1][j-b[i-1]][p-min(n, b[i-1])];
//                if (dp[i][j][p]) {
//                    cout << i << " " << j << " " << p << "\n";
//                }
            }
        }
    }

    for(int j = time; j < maxN*maxN; j++) {
        if (dp[m][j][k*n]) {
            ans = min(ans, j-time);
        }
    }

    if (ans == INF) {
        cout << "Impossible\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 8740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -