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

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

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



a.sort()

f.sort()

a = a[::-1]

kaketa = []

for i in range(n):

    kaketa.append(a[i]*f[i])



left = 0

right = max(kaketa)



while True:

    jiku = (left+right)//2

    kaisuu = 0

    for i in range(n):

        if kaketa[i] - jiku > 0:

            if (kaketa[i] - jiku) % f[i] != 0:

                kaisuu += (kaketa[i] - jiku) // f[i] + 1

            else:

                kaisuu += (kaketa[i] - jiku) // f[i]

    if kaisuu > k:

        left = jiku

    else:

        right = jiku

    if right - left == 1:

        break



if sum(a) <= k:

    print((0))

else:

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

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

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



a.sort()

f.sort(reverse=True)

lst = []

maxi = 0

for i in range(n):

    lst.append([a[i]*f[i], f[i]])

    maxi = max(maxi, a[i]*f[i])



left = -1 # 不可能

right = maxi # 可能

while left+1 < right:

    mid = (left+right)//2

    cnt = 0

    for i in range(n):

        lsti = lst[i]

        if lsti[0] > mid:

            sa = lsti[0] - mid

            cnt += (sa+lsti[1]-1) // lsti[1]

    if cnt <= k:

        right = mid

    else:

        left = mid

print(right)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort()
a = a[::-1]
kaketa = []
for i in range(n):
    kaketa.append(a[i] * f[i])
left = 0
right = max(kaketa)
while True:
    jiku = (left + right) // 2
    kaisuu = 0
    for i in range(n):
        if kaketa[i] - jiku > 0:
            if (kaketa[i] - jiku) % f[i] != 0:
                kaisuu += (kaketa[i] - jiku) // f[i] + 1
            else:
                kaisuu += (kaketa[i] - jiku) // f[i]
    if kaisuu > k:
        left = jiku
    else:
        right = jiku
    if right - left == 1:
        break
if sum(a) <= k:
    print((0))
else:
    print(right)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
lst = []
maxi = 0
for i in range(n):
    lst.append([a[i] * f[i], f[i]])
    maxi = max(maxi, a[i] * f[i])
left = -1  # 不可能
right = maxi  # 可能
while left + 1 < right:
    mid = (left + right) // 2
    cnt = 0
    for i in range(n):
        lsti = lst[i]
        if lsti[0] > mid:
            sa = lsti[0] - mid
            cnt += (sa + lsti[1] - 1) // lsti[1]
    if cnt <= k:
        right = mid
    else:
        left = mid
print(right)

-f.sort() -a = a[::-1] -kaketa = [] +f.sort(reverse=True) +lst = [] +maxi = 0 -    kaketa.append(a[i] * f[i]) -left = 0 -right = max(kaketa) -while True: -    jiku = (left + right) // 2 -    kaisuu = 0 +    lst.append([a[i] * f[i], f[i]]) +    maxi = max(maxi, a[i] * f[i]) +left = -1  # 不可能 +right = maxi  # 可能 +while left + 1 < right: +    mid = (left + right) // 2 +    cnt = 0 -        if kaketa[i] - jiku > 0: -            if (kaketa[i] - jiku) % f[i] != 0: -                kaisuu += (kaketa[i] - jiku) // f[i] + 1 -            else: -                kaisuu += (kaketa[i] - jiku) // f[i] -    if kaisuu > k: -        left = jiku +        lsti = lst[i] +        if lsti[0] > mid: +            sa = lsti[0] - mid +            cnt += (sa + lsti[1] - 1) // lsti[1] +    if cnt <= k: +        right = mid -        right = jiku -    if right - left == 1: -        break -if sum(a) <= k: -    print((0)) -else: -    print(right) +        left = mid +print(right)