This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 + m + 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |