Submission #1108224

# Submission time Handle Problem Language Result Execution time Memory
1108224 2024-11-03T11:24:04 Z Acanikolic Kitchen (BOI19_kitchen) C++14
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>

#define int long long

#define pb push_back

#define F first

#define S second

using namespace std;

const int N = 2e5 + 10;

const int mod = 1e9 + 7;

const int inf = 1e18;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m,k;
    cin >> n >> m >> k;
    if(m < n) {
        cout << "Impossible";
        return 0;
    }
    vector<int>a(n + 1);
    int sa = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sa += a[i];
        if(a[i] < k) {
            cout << "Impossible";
            return 0;
        }
    }
    vector<int>b(m + 1);
    int sum = 0;
    for(int i = 1; i <= m; i++) {
        cin >> b[i];
        sum += b[i];
    }
    vector<int>dp(sum + 1,inf);
    dp[0] = 0;
    for(int i = 1; i <= m; i++) {
        vector<int>ndp = dp;
        for(int j = b[i]; j <= sum; j++) {
            ndp[j] = min(ndp[j],dp[j - b[i]] + min(b[i],n));
        }
        dp = ndp;
    }
    int res = inf;
    for(int i = 0; i <= sum; i++) {
        if(dp[i] >= n * k && dp[i] != inf) res = min(res,abs(i - sa));
    }
    if(res == inf) {
        cout << "Impossible";
    }else {
        cout << res;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -