Submission #494045

# Submission time Handle Problem Language Result Execution time Memory
494045 2021-12-14T02:24:06 Z SirCovidThe19th Kitchen (BOI19_kitchen) C++17
0 / 100
63 ms 102408 KB
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, x, y) for (int i = x; i < y; i++)

int n, m, k, sm, bad = 0, ans = 1e9, A[305], B[305], dp[305][100005];

int main(){
    cin >> n >> m >> k;
    FOR(i, 1, n + 1) cin >> A[i], sm += A[i], bad |= (A[i] < k);
    FOR(i, 1, m + 1) cin >> B[i];

    FOR(i, 1, m + 1) FOR(j, 1, 100005) if (j - B[i] >= 0){

        dp[i][j] = dp[i - 1][j - B[i]] + min(B[i], n);
        if (j >= sm and dp[i][j] >= n * k) ans = min(ans, j - sm);  
    }
    cout<<((bad or ans == 1e9) ? "Impossible" : to_string(ans))<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Incorrect 1 ms 972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Incorrect 1 ms 972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 102408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 15916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Incorrect 1 ms 972 KB Output isn't correct
3 Halted 0 ms 0 KB -