Submission #746054

# Submission time Handle Problem Language Result Execution time Memory
746054 2023-05-21T10:53:16 Z vjudge1 Kitchen (BOI19_kitchen) C++11
100 / 100
106 ms 764 KB
#include <bits/stdc++.h>

using namespace std;

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

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 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 612 KB Output is correct
2 Correct 32 ms 604 KB Output is correct
3 Correct 67 ms 596 KB Output is correct
4 Correct 103 ms 704 KB Output is correct
5 Correct 95 ms 764 KB Output is correct
6 Correct 32 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 42 ms 612 KB Output is correct
15 Correct 32 ms 604 KB Output is correct
16 Correct 67 ms 596 KB Output is correct
17 Correct 103 ms 704 KB Output is correct
18 Correct 95 ms 764 KB Output is correct
19 Correct 32 ms 596 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 25 ms 596 KB Output is correct
26 Correct 37 ms 600 KB Output is correct
27 Correct 21 ms 468 KB Output is correct
28 Correct 58 ms 596 KB Output is correct
29 Correct 72 ms 596 KB Output is correct
30 Correct 106 ms 724 KB Output is correct