Submission #657381

#TimeUsernameProblemLanguageResultExecution timeMemory
657381bicsiKitchen (BOI19_kitchen)C++14
100 / 100
44 ms724 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; int g = 0; for (int i = 0; i < n; ++i) { int ai; cin >> ai; if (ai < k) { cout << "Impossible\n"; return 0; } g += ai; } vector<int> dp(100000, -1e9); dp[0] = 0; int mx = 0; for (int i = 0; i < m; ++i) { int bi; cin >> bi; int val = min(bi, n); for (int j = mx; j >= 0; --j) if (dp[j] >= 0) dp[j + bi] = max(dp[j + bi], dp[j] + val); mx += bi; } for (int i = g; i <= mx; ++i) if (dp[i] >= n * k) { cout << i - g << endl; return 0; } cout << "Impossible\n"; return 0; }
#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...