import math

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

A = sorted(list(map(int,input().split())))

F = sorted(list(map(int,input().split())),reverse=True)

high = 0

for i in range(N):

    high = max(high,A[i]*F[i])

low = -1

while high-low>1:

    mid = (high+low)//2

    flag = 1

    T = K

    for i in range(N):

        if A[i]*F[i]<=mid:continue

        else:

            T -= math.ceil(A[i]-mid/F[i])

            if T<0:

                flag = 0

                break

    if flag==1:

        high = mid

    else:

        low = mid

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

A = sorted(list(map(int,input().split())))

F = sorted(list(map(int,input().split())),reverse=True)

if K>=sum(A):

    ans = 0

else:

    low = 0

    high = 10**12

    while high-low>1:

        mid = (high+low)//2

        B = A[:]

        cnt = 0

        for i in range(N):

            if B[i]*F[i]>mid:

                cnt += (B[i]-mid//F[i])

        if cnt<=K:

            high = mid

        else:

            low = mid

    ans = high

print(ans)
import math

N, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)
high = 0
for i in range(N):
    high = max(high, A[i] * F[i])
low = -1
while high - low > 1:
    mid = (high + low) // 2
    flag = 1
    T = K
    for i in range(N):
        if A[i] * F[i] <= mid:
            continue
        else:
            T -= math.ceil(A[i] - mid / F[i])
            if T < 0:
                flag = 0
                break
    if flag == 1:
        high = mid
    else:
        low = mid
print(high)

N, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)
if K >= sum(A):
    ans = 0
else:
    low = 0
    high = 10**12
    while high - low > 1:
        mid = (high + low) // 2
        B = A[:]
        cnt = 0
        for i in range(N):
            if B[i] * F[i] > mid:
                cnt += B[i] - mid // F[i]
        if cnt <= K:
            high = mid
        else:
            low = mid
    ans = high
print(ans)

-import math - -high = 0 -for i in range(N): -    high = max(high, A[i] * F[i]) -low = -1 -while high - low > 1: -    mid = (high + low) // 2 -    flag = 1 -    T = K -    for i in range(N): -        if A[i] * F[i] <= mid: -            continue +if K >= sum(A): +    ans = 0 +else: +    low = 0 +    high = 10**12 +    while high - low > 1: +        mid = (high + low) // 2 +        B = A[:] +        cnt = 0 +        for i in range(N): +            if B[i] * F[i] > mid: +                cnt += B[i] - mid // F[i] +        if cnt <= K: +            high = mid -            T -= math.ceil(A[i] - mid / F[i]) -            if T < 0: -                flag = 0 -                break -    if flag == 1: -        high = mid -    else: -        low = mid -print(high) +            low = mid +    ans = high +print(ans)