Submission #746052

# Submission time Handle Problem Language Result Execution time Memory
746052 2023-05-21T10:51:47 Z vjudge1 Kitchen (BOI19_kitchen) C++11
72 / 100
62 ms 680 KB
#include <bits/stdc++.h>

using namespace std;

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

void subtask3() {
    vector<bool> g;
    vector<int> krit;
    g.assign(sum+1+w+w,0);
    krit.assign(sum+1+w+w,0);
    g[w]=1;
    for (int i=1;i<=m;i++) {
        for (int j=min(i*w,sum+w);j>max(0,sum-(m-i)*w-w);j--) {
            if (g[j+w-b[i]]==1) {
                g[j+w]=1;
                krit[j+w]=max(krit[j+w],krit[j+w-b[i]]+min(b[i],n));
            }
        }
    }
    int ans=-1;
    for (int i=sum+w;i<sum+w+w;i++) {
        if (g[i] && (krit[i]>=n*k)) {
            ans=i-w;
            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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 468 KB Output is correct
2 Correct 19 ms 544 KB Output is correct
3 Correct 50 ms 468 KB Output is correct
4 Correct 62 ms 596 KB Output is correct
5 Correct 43 ms 680 KB Output is correct
6 Correct 18 ms 540 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 0 ms 212 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 26 ms 468 KB Output is correct
15 Correct 19 ms 544 KB Output is correct
16 Correct 50 ms 468 KB Output is correct
17 Correct 62 ms 596 KB Output is correct
18 Correct 43 ms 680 KB Output is correct
19 Correct 18 ms 540 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Incorrect 15 ms 468 KB Output isn't correct
26 Halted 0 ms 0 KB -