import sys sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 class Bit: def __init__(self, op, e, n): self.op = op self.e = e self.n = n+1 self.table = [e() for _ in range(self.n)] def update(self, i, x): i += 1 while i < self.n: self.table[i] = self.op(self.table[i], x) i += i & -i # [0,i] def prod(self, i): i += 1 res = self.e() while i > 0: res = self.op(res,self.table[i]) i -= i & -i return res from collections import defaultdict # left # u-u1<=(t-t1)*k # u-u1<=kt-kt1 # kt1-u1<=kt-u # right # u1-u<=(t-t1)*k # u1-u<=kt-kt1 # kt1+u1<=kt+u n,k=LI() tt=LI() xx=LI() cc=LI() enc=set() for t,x in zip(tt,xx):enc.add(k*t+x) enc.add(0) enc={a:i for i,a in enumerate(sorted(enc))} m=len(enc) bit=Bit(max,lambda :-inf,m+5) bit.update(enc[0],0) for i in sorted(range(n),key=lambda i:k*tt[i]-xx[i]): t,x=tt[i],xx[i] if k*t-x<0:continue p=enc[k*t+x] mx=bit.prod(p) if mx==-inf:continue bit.update(p,mx+cc[i]) print(bit.prod(m))