Submission #136751

#TimeUsernameProblemLanguageResultExecution timeMemory
136751azategaKitchen (BOI19_kitchen)C++11
0 / 100
150 ms133828 KiB
#include <iostream>

using namespace std;

int cost[310];
int chefs[310];
int memo[310][110000];



int main()
{
    int n, m, k, sum = 0;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++){
        cin >> cost[i];
        sum += cost[i];
    }
    for(int i = 0; i < m; i++)
        cin >> chefs[i];

    for(int i = 0; i < n; i++){
        if(cost[i] < k){
            cout << "Impossible" << endl;
            return 0;
        }
    }

    for(int i = 0; i < 310; i++)
        for(int j = 0; j < 110000; j++)
            memo[i][j] = -1;

    for(int i = 0; i < 310; i++)
        memo[i][0] = 0;

    for(int i = 1; i <= m; i++){
        for(int j = chefs[i - 1]; j < 110000; j++){
            memo[i][j] = memo[i - 1][j];

            if(memo[i - 1][j - chefs[i - 1]] != -1)
                memo[i][j] = max(memo[i][j], memo[i - 1][j - chefs[i - 1]] + min(chefs[i - 1], n));
        }
    }

    int najbolje = 99999997;
    for(int i = 100000; i >= sum; i--)
        if(memo[m][i] >= k * n)
            najbolje = i;

    if(najbolje != 99999997)
        cout << najbolje << endl;
    else
        cout << "Impossible" << endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...