#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
bool dp[301][90001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, k, sm = 0;
cin >> n >> m >> k;
if (m < k) return cout << "Impossible", 0;
FOR(i, 0, n) {
int a;
cin >> a;
if (a < k) return cout << "Impossible", 0;
sm += a;
}
dp[0][0] = true;
FOR(i, 1, m + 1) {
int x;
cin >> x;
FOR(j, 0, x) dp[i][j] = dp[i - 1][j];
FOR(j, x, 90001) dp[i][j] = dp[i - 1][j] || dp[i - 1][j - x];
}
FOR(i, sm, 90001) if (dp[m][i]) return cout << i - sm, 0;
cout << "Impossible";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
23288 KB |
Output is correct |
2 |
Correct |
36 ms |
20216 KB |
Output is correct |
3 |
Correct |
46 ms |
26744 KB |
Output is correct |
4 |
Correct |
46 ms |
26756 KB |
Output is correct |
5 |
Correct |
45 ms |
25848 KB |
Output is correct |
6 |
Correct |
34 ms |
18652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
3892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |