#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int MAXN = 312;
const int MAXS = MAXN * MAXN;
bool dp[MAXS];
vector<int> a, b;
int resp;
int n, m, k, sum_a;
void solve() {
resp = INF;
cin >> n >> m >> k;
a.resize(n); b.resize(m);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] < k) {
cout << "Impossible\n";
return;
}
sum_a += a[i];
}
dp[0] = true;
for (int i = 0; i < m; i++) {
cin >> b[i];
for (int x = MAXS - 1; x >= b[i]; x--) {
if (dp[x - b[i]]) {
dp[x] = true;
}
}
}
for (int s = sum_a; s < MAXS; s++) {
if (dp[s]) {
cout << s - sum_a << "\n";
return;
}
}
cout << "Impossible\n";
}
int32_t main() {
solve();
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... |