N, K = list(map(int, input().split()))

A = [int(c) for c in input().split()]

F = [int(c) for c in input().split()]

A.sort()

F.sort(reverse=True)

M = 0

for i in range(N):

  if A[i]*F[i]>M:

    M = A[i]*F[i]



l = -1

r = M+1

while l+1<r:

  s = (l+r)//2

  cnt = 0

  for i in range(N):

    b = s//F[i]

    cnt += max(0, A[i]-b)

  if cnt>K:

    l = s

  else:

    r = s



print(r)

import numpy as np

N, K = list(map(int, input().split()))

A = [int(c) for c in input().split()]

F = [int(c) for c in input().split()]

A.sort()

F.sort(reverse=True)

A = np.array(A)

F = np.array(F)

Asum = A.sum()

M = np.max(A*F)



l = -1

r = M+1

while l+1<r:

  s = (l+r)//2

  cnt = Asum - np.minimum(A, s//F).sum()

  if cnt>K:

    l = s

  else:

    r = s



print(r)
N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
M = 0
for i in range(N):
    if A[i] * F[i] > M:
        M = A[i] * F[i]
l = -1
r = M + 1
while l + 1 < r:
    s = (l + r) // 2
    cnt = 0
    for i in range(N):
        b = s // F[i]
        cnt += max(0, A[i] - b)
    if cnt > K:
        l = s
    else:
        r = s
print(r)

import numpy as np

N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)
Asum = A.sum()
M = np.max(A * F)
l = -1
r = M + 1
while l + 1 < r:
    s = (l + r) // 2
    cnt = Asum - np.minimum(A, s // F).sum()
    if cnt > K:
        l = s
    else:
        r = s
print(r)

+import numpy as np + -M = 0 -for i in range(N): -    if A[i] * F[i] > M: -        M = A[i] * F[i] +A = np.array(A) +F = np.array(F) +Asum = A.sum() +M = np.max(A * F) -    cnt = 0 -    for i in range(N): -        b = s // F[i] -        cnt += max(0, A[i] - b) +    cnt = Asum - np.minimum(A, s // F).sum()