Submission #1004382

# Submission time Handle Problem Language Result Execution time Memory
1004382 2024-06-21T08:24:48 Z coolboy19521 Kitchen (BOI19_kitchen) C++17
0 / 100
63 ms 348 KB
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
#define int long long

using namespace std;

const int sz = 3e2 + 6;

int a[sz], b[sz];

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int n, m, k;
    cin >> n >> m >> k;

    int sm = 0;

    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        sm += a[i];
    }

    for (int i = 1; i <= m; i ++) {
        cin >> b[i];
    }

    if (k > m) {
        cout << "Impossible";
        return 0;
    }

    if (1 == m) {
        int r = (sm / b[1]) * b[1];
        if (r < sm) r += b[1];
        cout << r - sm;
    } else if (2 == m) {
        int r = INT_MAX;
        int d = 2 == k;
        for (int i = d; i <= 10000; i ++) {
            for (int j = d; j <= 10000; j ++) {
                if (i * b[1] + j * b[2] >= sm) {
                    r = min(r, i * b[1] + j * b[2] - sm);
                }
            }
        }
        cout << r;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 56 ms 344 KB Output is correct
2 Correct 63 ms 348 KB Output is correct
3 Incorrect 61 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 344 KB Output is correct
2 Correct 63 ms 348 KB Output is correct
3 Incorrect 61 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 344 KB Output is correct
2 Correct 63 ms 348 KB Output is correct
3 Incorrect 61 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -