Submission #858327

#TimeUsernameProblemLanguageResultExecution timeMemory
858327Trisanu_DasKitchen (BOI19_kitchen)C++17
100 / 100
38 ms856 KiB
#include <bits/stdc++.h> using namespace std; int n, m, k, a, sum = 0; vector <int> ks(1e5 + 1, -1e9); int main() { cin >> n >> m >> k; for (int i = 0; i < n; i++) { cin >> a; sum += a; if (a < k) { cout << "Impossible"; return 0; } } ks[0] = 0; for (int i = 0; i < m; i++) { cin >> a; for (int j = 1e5; j >= a; j--) ks[j] = max(ks[j], ks[j - a] + min(a, n)); } for (int i = sum; i <= 1e5; i++) { if (ks[i] < n * k) continue; cout << i - sum; return 0; } cout << "Impossible\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...