import numpy as np

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

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

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



A=np.array(sorted(A, reverse=True))

F=np.array(sorted(F))



lower_bound=0

upper_bound=np.max(A*F)

K_tmp=0



while upper_bound>=lower_bound:

    mid=(lower_bound+upper_bound)//2

    K_tmp=np.sum(np.maximum(A-mid//F, 0))

    if K_tmp<=K:

        upper_bound=mid-1

    else:

        lower_bound=mid+1



print(lower_bound)
n,k=list(map(int,input().split()))

*a,= list(map(int,input().split()))

*f,= list(map(int,input().split()))

a=sorted(a)

f=sorted(f, reverse=True)



def is_ok(arg):

    cnt=0

    for i in range(n):

        cnt+=max(a[i]-arg//f[i], 0)

    return cnt<=k



def meguru_bisect(ng, ok):

    while (abs(ok - ng) > 1):

        mid = (ok + ng) // 2

        if is_ok(mid):

            ok = mid

        else:

            ng = mid

    return ok



print((meguru_bisect(-1, 10**12)))
import numpy as np

N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
F = [int(i) for i in input().split()]
A = np.array(sorted(A, reverse=True))
F = np.array(sorted(F))
lower_bound = 0
upper_bound = np.max(A * F)
K_tmp = 0
while upper_bound >= lower_bound:
    mid = (lower_bound + upper_bound) // 2
    K_tmp = np.sum(np.maximum(A - mid // F, 0))
    if K_tmp <= K:
        upper_bound = mid - 1
    else:
        lower_bound = mid + 1
print(lower_bound)

n, k = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
(*f,) = list(map(int, input().split()))
a = sorted(a)
f = sorted(f, reverse=True)


def is_ok(arg):
    cnt = 0
    for i in range(n):
        cnt += max(a[i] - arg // f[i], 0)
    return cnt <= k


def meguru_bisect(ng, ok):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


print((meguru_bisect(-1, 10**12)))

-import numpy as np +n, k = list(map(int, input().split())) +(*a,) = list(map(int, input().split())) +(*f,) = list(map(int, input().split())) +a = sorted(a) +f = sorted(f, reverse=True) -N, K = list(map(int, input().split())) -A = [int(i) for i in input().split()] -F = [int(i) for i in input().split()] -A = np.array(sorted(A, reverse=True)) -F = np.array(sorted(F)) -lower_bound = 0 -upper_bound = np.max(A * F) -K_tmp = 0 -while upper_bound >= lower_bound: -    mid = (lower_bound + upper_bound) // 2 -    K_tmp = np.sum(np.maximum(A - mid // F, 0)) -    if K_tmp <= K: -        upper_bound = mid - 1 -    else: -        lower_bound = mid + 1 -print(lower_bound) + +def is_ok(arg): +    cnt = 0 +    for i in range(n): +        cnt += max(a[i] - arg // f[i], 0) +    return cnt <= k + + +def meguru_bisect(ng, ok): +    while abs(ok - ng) > 1: +        mid = (ok + ng) // 2 +        if is_ok(mid): +            ok = mid +        else: +            ng = mid +    return ok + + +print((meguru_bisect(-1, 10**12)))