#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int M = 3e2+5, MOD = 1e9+7;
int dp[M][M*M];
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
srand(time(0));
int n, m, k;
cin >> n >> m >> k;
if (k > m) {
cout << "Impossible" << endl;
return 0;
}
vector<int> meal(n), cock(m);
int s = 0;
for (int&i:meal) cin >> i;
for (int i:meal) s += i;
for (int&i:cock) cin >> i;
sort(cock.begin(), cock.end());
for (int i = 1; i <= n; i++) dp[i][0] = 1;
for (int i = 1; i <= n; i++) {
for (int x = 1; x < M*M; x++) {
dp[i][x] |= dp[i][x-cock[i-1]];
}
}
for (int i = s; i < M; i++) {
if (dp[n][i]) {
cout << i-s << endl;
return 0;
}
} cout << "Impossible" << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
108 ms |
216464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
19256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |