import array
N = 300
n,m,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
supply = array.array('i', [-N*N for i in range(N*N+1)])
supply[0] = 0;
def solve():
if(min(a) < k):
return 'Impossible'
bsum = 0
for x in b:
bsum += x
for i in range(bsum,-1,-1):
supply[i+x] = max(supply[i+x],supply[i]+min(x,n))
for i in range(sum(a),N*N+1):
if(supply[i] >= n*k):
return i-sum(a)
return 'Impossible'
print(solve())
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
7356 KB |
Output is correct |
2 |
Correct |
45 ms |
7356 KB |
Output is correct |
3 |
Correct |
50 ms |
7356 KB |
Output is correct |
4 |
Correct |
45 ms |
7356 KB |
Output is correct |
5 |
Correct |
45 ms |
7388 KB |
Output is correct |
6 |
Correct |
45 ms |
7340 KB |
Output is correct |
7 |
Correct |
46 ms |
7336 KB |
Output is correct |
8 |
Correct |
63 ms |
7416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
7356 KB |
Output is correct |
2 |
Correct |
45 ms |
7356 KB |
Output is correct |
3 |
Correct |
50 ms |
7356 KB |
Output is correct |
4 |
Correct |
45 ms |
7356 KB |
Output is correct |
5 |
Correct |
45 ms |
7388 KB |
Output is correct |
6 |
Correct |
45 ms |
7340 KB |
Output is correct |
7 |
Correct |
46 ms |
7336 KB |
Output is correct |
8 |
Correct |
63 ms |
7416 KB |
Output is correct |
9 |
Correct |
68 ms |
7348 KB |
Output is correct |
10 |
Correct |
63 ms |
7340 KB |
Output is correct |
11 |
Correct |
64 ms |
7308 KB |
Output is correct |
12 |
Correct |
46 ms |
7356 KB |
Output is correct |
13 |
Correct |
75 ms |
7340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1062 ms |
7452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
7348 KB |
Output is correct |
2 |
Correct |
62 ms |
7392 KB |
Output is correct |
3 |
Correct |
71 ms |
7460 KB |
Output is correct |
4 |
Correct |
74 ms |
7304 KB |
Output is correct |
5 |
Correct |
47 ms |
7340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
7356 KB |
Output is correct |
2 |
Correct |
45 ms |
7356 KB |
Output is correct |
3 |
Correct |
50 ms |
7356 KB |
Output is correct |
4 |
Correct |
45 ms |
7356 KB |
Output is correct |
5 |
Correct |
45 ms |
7388 KB |
Output is correct |
6 |
Correct |
45 ms |
7340 KB |
Output is correct |
7 |
Correct |
46 ms |
7336 KB |
Output is correct |
8 |
Correct |
63 ms |
7416 KB |
Output is correct |
9 |
Correct |
68 ms |
7348 KB |
Output is correct |
10 |
Correct |
63 ms |
7340 KB |
Output is correct |
11 |
Correct |
64 ms |
7308 KB |
Output is correct |
12 |
Correct |
46 ms |
7356 KB |
Output is correct |
13 |
Correct |
75 ms |
7340 KB |
Output is correct |
14 |
Execution timed out |
1062 ms |
7452 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |