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;
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 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... |