Submission #386554

# Submission time Handle Problem Language Result Execution time Memory
386554 2021-04-06T19:30:15 Z Uncreative Kitchen (BOI19_kitchen) C++14
21 / 100
127 ms 117612 KB
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int n, m, k;
const int maxn = 310;
const int inf = maxn * maxn + 400;

int a[maxn];
int az = 0;

int b[maxn];

int dp[maxn][inf];

int sol = inf;

int main(){
    memset(dp, -1, sizeof(dp));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> k;
    int r = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        az += a[i];
        if (a[i] < k){
            r = 1;
        }
    }
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }
    dp[m][0] = 0;
    for (int i = m - 1; i >= 0; i--){
        for (int j = maxn * maxn; j >= 0; j--){
            //dp[i][j] = dp[i + 1][j - b[i]] + min(n, b[i]);
            dp[i][j] = dp[i + 1][j];
            dp[i][j + b[i]] = max(dp[i][j + b[i]], dp[i + 1][j] + min(n, b[i]));
        }
    }
    //cout << az << endl;
    for (int j = maxn * maxn; j >= 0; j--){
        if (dp[0][j] >= k * n && j >= az){
            sol = min(sol, j);
        }
    }
    if (r == 0 && sol != inf){
        cout << sol - az;
    }
    else {
        cout << "Impossible";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 59 ms 117356 KB Output is correct
2 Correct 60 ms 117356 KB Output is correct
3 Correct 59 ms 117484 KB Output is correct
4 Correct 59 ms 117484 KB Output is correct
5 Correct 61 ms 117612 KB Output is correct
6 Correct 60 ms 117484 KB Output is correct
7 Correct 78 ms 117484 KB Output is correct
8 Incorrect 61 ms 117484 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 117356 KB Output is correct
2 Correct 60 ms 117356 KB Output is correct
3 Correct 59 ms 117484 KB Output is correct
4 Correct 59 ms 117484 KB Output is correct
5 Correct 61 ms 117612 KB Output is correct
6 Correct 60 ms 117484 KB Output is correct
7 Correct 78 ms 117484 KB Output is correct
8 Incorrect 61 ms 117484 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 117484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 117356 KB Output is correct
2 Correct 64 ms 117356 KB Output is correct
3 Correct 75 ms 117356 KB Output is correct
4 Correct 74 ms 117484 KB Output is correct
5 Correct 65 ms 117356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 117356 KB Output is correct
2 Correct 60 ms 117356 KB Output is correct
3 Correct 59 ms 117484 KB Output is correct
4 Correct 59 ms 117484 KB Output is correct
5 Correct 61 ms 117612 KB Output is correct
6 Correct 60 ms 117484 KB Output is correct
7 Correct 78 ms 117484 KB Output is correct
8 Incorrect 61 ms 117484 KB Output isn't correct