Submission #131101

#TimeUsernameProblemLanguageResultExecution timeMemory
131101IOrtroiiiKitchen (BOI19_kitchen)C++14
100 / 100
29 ms788 KiB
#include <bits/stdc++.h> using namespace std; const int N = 305; const int M = N * N; int a[N]; int b[N]; int f[M]; int main() { ios_base::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= m; ++i) { cin >> b[i]; } if (*min_element(a + 1, a + n + 1) < k) { cout << "Impossible\n"; return 0; } memset(f, -69, sizeof f); f[0] = 0; for (int i = 1; i <= m; ++i) { for (int j = M - 1; j >= b[i]; --j) { f[j] = max(f[j], f[j - b[i]] + min(b[i], n)); } } int sum = accumulate(a + 1, a + n + 1, 0); for (int i = sum; i < M; ++i) { if (f[i] >= n * k) { cout << i - sum << "\n"; 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...