import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets import critbits, future, strformat, deques,heapqueue template `max=`(x,y) = x = max(x,y) template `min=`(x,y) = x = min(x,y) template `mod=`(x,y) = x = x mod y template scan2 = (scan(), scan()) template scan3 = (scan(), scan()) let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) proc scan(): int = read().parseInt proc scanf(): float = read().parseFloat proc toInt(c:char): int = return int(c) - int('0') proc solve():int= var n = scan() x = scan() aseq = newseqwith(n,scan()-x) bseq = newseqwith(n,scan()) if aseq.sum()>=0: return 0 else: if aseq.filterIt(it>=0).len==0: return -1 var ma = newseq[int]() mb = newseq[int]() goal = -aseq.sum() mx = 500*100 for i in 0..=0: dp[i][j] = min(dp[i-1][j], dp[i-1][j-ma[i-1]]+mb[i-1]) else: dp[i][j].min=dp[i-1][j] if j>=goal: result.min=dp[i][j] echo solve()