#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
int n, m, k, sm, bad = 0, ans = 1e9, A[305], B[305], dp[305][100005];
int main(){
cin >> n >> m >> k;
FOR(i, 1, n + 1) cin >> A[i], sm += A[i], bad |= (A[i] < k);
FOR(i, 1, m + 1) cin >> B[i];
memset(dp, -0x3f, sizeof(dp));
FOR(i, 0, m + 1) dp[i][0] = 0;
FOR(i, 1, m + 1) FOR(j, B[i], 100005){
dp[i][j] = dp[i - 1][j - B[i]] + min(B[i], n);
if (j >= sm and dp[i][j] >= n * k) ans = min(ans, j - sm);
}
cout<<((bad or ans == 1e9) ? "Impossible" : to_string(ans))<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
119588 KB |
Output is correct |
2 |
Correct |
43 ms |
119536 KB |
Output is correct |
3 |
Correct |
46 ms |
119600 KB |
Output is correct |
4 |
Correct |
45 ms |
119620 KB |
Output is correct |
5 |
Correct |
44 ms |
119552 KB |
Output is correct |
6 |
Correct |
49 ms |
119616 KB |
Output is correct |
7 |
Correct |
45 ms |
119668 KB |
Output is correct |
8 |
Correct |
52 ms |
119616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
119588 KB |
Output is correct |
2 |
Correct |
43 ms |
119536 KB |
Output is correct |
3 |
Correct |
46 ms |
119600 KB |
Output is correct |
4 |
Correct |
45 ms |
119620 KB |
Output is correct |
5 |
Correct |
44 ms |
119552 KB |
Output is correct |
6 |
Correct |
49 ms |
119616 KB |
Output is correct |
7 |
Correct |
45 ms |
119668 KB |
Output is correct |
8 |
Correct |
52 ms |
119616 KB |
Output is correct |
9 |
Incorrect |
49 ms |
119560 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
119608 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
119620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
119588 KB |
Output is correct |
2 |
Correct |
43 ms |
119536 KB |
Output is correct |
3 |
Correct |
46 ms |
119600 KB |
Output is correct |
4 |
Correct |
45 ms |
119620 KB |
Output is correct |
5 |
Correct |
44 ms |
119552 KB |
Output is correct |
6 |
Correct |
49 ms |
119616 KB |
Output is correct |
7 |
Correct |
45 ms |
119668 KB |
Output is correct |
8 |
Correct |
52 ms |
119616 KB |
Output is correct |
9 |
Incorrect |
49 ms |
119560 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |