# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311324 | 2020-10-09T23:14:52 Z | VROOM_VARUN | Kitchen (BOI19_kitchen) | Python 3 | 0 ms | 0 KB |
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())