Submission #1004390

# Submission time Handle Problem Language Result Execution time Memory
1004390 2024-06-21T08:28:45 Z coolboy19521 Kitchen (BOI19_kitchen) C++17
0 / 100
223 ms 432 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;
        for (int i = 0; i <= 1e8; i ++) {
            int j = (sm - i * b[1]) / b[2];
            if (sm - i * b[1] + j * b[2] > 0) j ++;
            if (2 == k && (0 >= i || 0 >= j)) {
                continue;
            }
            r = min(r, i * b[1] + j * b[2] - sm);
        }
        cout << r;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 432 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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -