Submission #917998

#TimeUsernameProblemLanguageResultExecution timeMemory
917998borisAngelovKitchen (BOI19_kitchen)C++17
20 / 100
1 ms488 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 305; const int maxsum = maxn * maxn; int n, m, k; int a[maxn]; int b[maxn]; bitset<maxsum> dp; void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n >> m >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= m; ++i) { cin >> b[i]; } dp[0] = true; for (int i = 1; i <= m; ++i) { dp |= (dp << b[i]); } int target = 0; for (int i = 1; i <= n; ++i) { target += a[i]; } for (int i = target; i < maxsum; ++i) { if (dp[i] == true) { cout << i - target << endl; return 0; } } cout << "Impossible" << endl; 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...