Submission #858314

#TimeUsernameProblemLanguageResultExecution timeMemory
858314Trisanu_DasKitchen (BOI19_kitchen)C++17
21 / 100
38 ms111456 KiB
#include <bits/stdc++.h> using namespace std; int barr[305], dp[305][305 * 305]; int main(){ int n, m, k; cin >> n >> m >> k; int total = 0; for (int i = 0; i < n; i++){ int a; cin >> a; if (a < k){ cout << "Impossible\n"; return 0; } total += a; } for (int i = 0; i < m; i++) cin >> barr[i]; memset(dp, INT_MIN, sizeof(dp)); dp[0][barr[0]] = min(n, barr[0]); for (int i = 1; i < m; i++){ for (int j = 0; j < 305 * 305; j++){ dp[i][j] = dp[i-1][j]; if (barr[i] <= j) dp[i][j] = max(dp[i][j], dp[i-1][j - barr[i]] + min(n, barr[i])); } } bool pos = 0; int ans; for (int i = total; i < 305 * 305; i++){ if (dp[m-1][i] >= n * k){ pos = 1; ans = i; break; } } if (!pos) cout << "Impossible\n"; else cout << ans - total << '\n'; }
#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...