import numpy as np



def is_ok(mid, k):

    s = np.maximum(a - mid // f, 0).sum()

    if s <= k:

        return True

    else:

        return False



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

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

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

a.sort()

f.sort(reverse=True)

a = np.array(a)

f = np.array(f)



l, r = -1, np.max(a * f) # l:ng, r:ok

while l + 1 < r:

    mid = (l + r) // 2

    if is_ok(mid, k):

        r = mid

    else:

        l = mid

print(r)
import numpy as np



def is_ok(mid, k):

    s = np.maximum(a - mid // f, 0).sum()

    if s <= k:

        return True

    else:

        return False



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

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

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

a = np.sort(a)

f = np.sort(f)[::-1]



l, r = -1, np.max(a * f) # l:ng, r:ok

while l + 1 < r:

    mid = (l + r) // 2

    if is_ok(mid, k):

        r = mid

    else:

        l = mid

print(r)
import numpy as np


def is_ok(mid, k):
    s = np.maximum(a - mid // f, 0).sum()
    if s <= k:
        return True
    else:
        return False


n, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
a.sort()
f.sort(reverse=True)
a = np.array(a)
f = np.array(f)
l, r = -1, np.max(a * f)  # l:ng, r:ok
while l + 1 < r:
    mid = (l + r) // 2
    if is_ok(mid, k):
        r = mid
    else:
        l = mid
print(r)

import numpy as np


def is_ok(mid, k):
    s = np.maximum(a - mid // f, 0).sum()
    if s <= k:
        return True
    else:
        return False


n, k = list(map(int, input().split()))
a = np.array(list(map(int, input().split())))
f = np.array(list(map(int, input().split())))
a = np.sort(a)
f = np.sort(f)[::-1]
l, r = -1, np.max(a * f)  # l:ng, r:ok
while l + 1 < r:
    mid = (l + r) // 2
    if is_ok(mid, k):
        r = mid
    else:
        l = mid
print(r)

-a = [int(i) for i in input().split()] -f = [int(i) for i in input().split()] -a.sort() -f.sort(reverse=True) -a = np.array(a) -f = np.array(f) +a = np.array(list(map(int, input().split()))) +f = np.array(list(map(int, input().split()))) +a = np.sort(a) +f = np.sort(f)[::-1]