Submission #136746

# Submission time Handle Problem Language Result Execution time Memory
136746 2019-07-26T08:08:22 Z azatega Kitchen (BOI19_kitchen) C++11
50 / 100
177 ms 133908 KB
#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;

    int najbolje = 99999997;

    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));

            if(j >= sum && memo[i][j] >= k*n){
                najbolje = min(najbolje, j - sum);
            }
        }
    }

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

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 118 ms 133908 KB Output is correct
2 Correct 117 ms 133752 KB Output is correct
3 Correct 116 ms 133752 KB Output is correct
4 Correct 119 ms 133820 KB Output is correct
5 Correct 116 ms 133772 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 116 ms 133884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 118 ms 133908 KB Output is correct
2 Correct 117 ms 133752 KB Output is correct
3 Correct 116 ms 133752 KB Output is correct
4 Correct 119 ms 133820 KB Output is correct
5 Correct 116 ms 133772 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 116 ms 133884 KB Output is correct
9 Correct 118 ms 133780 KB Output is correct
10 Correct 118 ms 133836 KB Output is correct
11 Correct 119 ms 133852 KB Output is correct
12 Correct 119 ms 133864 KB Output is correct
13 Incorrect 119 ms 133736 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 133752 KB Output is correct
2 Correct 154 ms 133752 KB Output is correct
3 Correct 169 ms 133880 KB Output is correct
4 Correct 170 ms 133696 KB Output is correct
5 Correct 177 ms 133772 KB Output is correct
6 Correct 152 ms 133752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 133852 KB Output is correct
2 Correct 124 ms 133752 KB Output is correct
3 Correct 125 ms 133804 KB Output is correct
4 Correct 123 ms 133756 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 118 ms 133908 KB Output is correct
2 Correct 117 ms 133752 KB Output is correct
3 Correct 116 ms 133752 KB Output is correct
4 Correct 119 ms 133820 KB Output is correct
5 Correct 116 ms 133772 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 116 ms 133884 KB Output is correct
9 Correct 118 ms 133780 KB Output is correct
10 Correct 118 ms 133836 KB Output is correct
11 Correct 119 ms 133852 KB Output is correct
12 Correct 119 ms 133864 KB Output is correct
13 Incorrect 119 ms 133736 KB Output isn't correct