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 main() {
int n, m, k; cin >> n >> m >> k;
int g = 0;
for (int i = 0; i < n; ++i) {
int ai; cin >> ai;
if (ai < k) {
cout << "Impossible\n";
return 0;
}
g += ai;
}
vector<int> dp(100000, -1e9);
dp[0] = 0;
int mx = 0;
for (int i = 0; i < m; ++i) {
int bi; cin >> bi;
int val = min(bi, n);
for (int j = mx; j >= 0; --j)
if (dp[j] >= 0)
dp[j + bi] = max(dp[j + bi], dp[j] + val);
mx += bi;
}
for (int i = g; i <= mx; ++i)
if (dp[i] >= n * k) {
cout << i - g << endl;
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... |