import sys

readline = sys.stdin.readline



import numpy as np



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

A = np.array(sorted(list(map(int,readline().split()))))

F = np.array(sorted(list(map(int,readline().split())),reverse = True))



ok = A[-1] * F[0]

ng = -1



def isOk(x):

  # 時間がxになるためには、A_iをx/F_i以下まで減らす必要がある

  return A.sum() - np.minimum(A,x // F).sum() <= K

  

while (ok - ng)>1:

  mid = (ok + ng) // 2

  if isOk(mid):

    ok = mid

  else:

    ng = mid

print(ok)
import sys

readline = sys.stdin.readline



import numpy as np



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

A = np.sort(np.array(readline().split(), dtype = int))

F = np.sort(np.array(readline().split(), dtype = int))[::-1]



# X秒で完食できるか二分探索



ng = -1

ok = F[0] * A[-1]



def isOk(x):

  return A.sum() - np.minimum(A, x // F).sum() <= K

  

while abs(ok - ng) > 1:

  mid = abs(ok + ng) // 2

  if isOk(mid):

    ok = mid

  else:

    ng = mid

    

print(ok)



import sys

readline = sys.stdin.readline
import numpy as np

N, K = list(map(int, readline().split()))
A = np.array(sorted(list(map(int, readline().split()))))
F = np.array(sorted(list(map(int, readline().split())), reverse=True))
ok = A[-1] * F[0]
ng = -1


def isOk(x):
    # 時間がxになるためには、A_iをx/F_i以下まで減らす必要がある
    return A.sum() - np.minimum(A, x // F).sum() <= K


while (ok - ng) > 1:
    mid = (ok + ng) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid
print(ok)

import sys

readline = sys.stdin.readline
import numpy as np

N, K = list(map(int, readline().split()))
A = np.sort(np.array(readline().split(), dtype=int))
F = np.sort(np.array(readline().split(), dtype=int))[::-1]
# X秒で完食できるか二分探索
ng = -1
ok = F[0] * A[-1]


def isOk(x):
    return A.sum() - np.minimum(A, x // F).sum() <= K


while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid
print(ok)

-A = np.array(sorted(list(map(int, readline().split())))) -F = np.array(sorted(list(map(int, readline().split())), reverse=True)) -ok = A[-1] * F[0] +A = np.sort(np.array(readline().split(), dtype=int)) +F = np.sort(np.array(readline().split(), dtype=int))[::-1] +# X秒で完食できるか二分探索 +ok = F[0] * A[-1] -    # 時間がxになるためには、A_iをx/F_i以下まで減らす必要がある -while (ok - ng) > 1: -    mid = (ok + ng) // 2 +while abs(ok - ng) > 1: +    mid = abs(ok + ng) // 2