Submission #494049

#TimeUsernameProblemLanguageResultExecution timeMemory
494049SirCovidThe19thKitchen (BOI19_kitchen)C++17
100 / 100
106 ms119748 KiB
#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]; memset(dp, -0x3f, sizeof(dp)); dp[0][0] = 0; FOR(i, 1, m + 1) FOR(j, 0, 100005){ dp[i][j] = dp[i - 1][j]; if (j - B[i] >= 0) dp[i][j] = max(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 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...