Submission #746020

# Submission time Handle Problem Language Result Execution time Memory
746020 2023-05-21T10:37:12 Z vjudge1 Kitchen (BOI19_kitchen) C++11
41 / 100
32 ms 640 KB
#include <bits/stdc++.h>

using namespace std;

int n,m,k;
int a[301];
int b[301];
int sum=0;

void subtask3() {
    vector<bool> g;
    vector<int> krit;
    g.assign(sum+1+300+300,0);
    krit.assign(sum+1+300+300,0);
    g[300]=1;
    for (int i=1;i<=m;i++) {
        for (int j=min(i*300,sum+1+300);j>max(0,sum-(m-i)*300-300);j--) {
            g[j+300]=g[j+300] | g[j+300-b[i]];

            if (g[j+300-b[i]]==1) {
                g[j+300]=1;
                krit[j+300]=max(krit[j+300],krit[j+300-b[i]]+min(b[i],n));
            }
        }
    }
    int ans=-1;
    for (int i=sum+300;i<sum+300+300;i++) {
        if (g[i] && (krit[i]>=n*k)) {
            ans=i-300;
            break;
        }
    }
    /*
    for (int i=0;i<g.size();i++) {
        cout << i << ": " << g[i] << endl;
    }
    cout << endl;
    */
    if (ans==-1) {
        cout << "Impossible" << endl;
    } else {
        cout << ans-sum << endl;
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    for (int i=1;i<=n;i++) {
        cin >> a[i];
        sum+=a[i];
    }
    for (int i=1;i<=m;i++) {
        cin >> b[i];
    }
    for (int i=1;i<=n;i++) {
        if (a[i]<k) {
            cout << "Impossible" << endl;
            return(0);
        }
    }
    subtask3();
    return 0;
}

/*
1 8 1
100
12 56 8 23 6 4 59 163
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 468 KB Output is correct
2 Correct 12 ms 468 KB Output is correct
3 Correct 32 ms 468 KB Output is correct
4 Correct 18 ms 640 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 9 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -