import numpy as np

from numba import njit



@njit

def solve(stdin):

    n, k = stdin[:2]

    A = stdin[2: 2 + n]

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

    F = np.sort(stdin[2 + n:])



    def is_ok(x):

        tmp = 0

        for a, f in zip(A, F):

            y = a * f

            if y > x:

                tmp += a - x // f

        return tmp <= k



    ok = 10 ** 16

    ng = -1

    while ok - ng > 1:

        mid = (ok + ng) // 2

        if is_ok(mid):

            ok = mid

        else:

            ng = mid



    return ok



print((solve(np.fromstring(open(0).read(), dtype=np.int64, sep=' '))))
import sys

import numpy as np



if sys.argv[-1] == 'ONLINE_JUDGE':

    from numba.pycc import CC

    cc = CC('my_module')



    @cc.export('is_ok', '(i8[:],i8[:],i8,i8)')

    def is_ok(A, F, x, k):

        tmp = 0

        for a, f in zip(A, F):

            y = a * f

            if y > x:

                tmp += a - x // f

        return tmp <= k



    cc.compile()

    exit(0)



from my_module import is_ok

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]



ok = 10 ** 16

ng = -1

while ok - ng > 1:

    mid = (ok + ng) // 2

    if is_ok(A, F, mid, k):

        ok = mid

    else:

        ng = mid



print(ok)

import numpy as np
from numba import njit


@njit
def solve(stdin):
    n, k = stdin[:2]
    A = stdin[2 : 2 + n]
    A = np.sort(A)[::-1]
    F = np.sort(stdin[2 + n :])

    def is_ok(x):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    ok = 10**16
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


print((solve(np.fromstring(open(0).read(), dtype=np.int64, sep=" "))))

import sys
import numpy as np

if sys.argv[-1] == "ONLINE_JUDGE":
    from numba.pycc import CC

    cc = CC("my_module")

    @cc.export("is_ok", "(i8[:],i8[:],i8,i8)")
    def is_ok(A, F, x, k):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    cc.compile()
    exit(0)
from my_module import is_ok

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]
ok = 10**16
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid
print(ok)

+import sys -from numba import njit +if sys.argv[-1] == "ONLINE_JUDGE": +    from numba.pycc import CC -@njit -def solve(stdin): -    n, k = stdin[:2] -    A = stdin[2 : 2 + n] -    A = np.sort(A)[::-1] -    F = np.sort(stdin[2 + n :]) +    cc = CC("my_module") -    def is_ok(x): +    @cc.export("is_ok", "(i8[:],i8[:],i8,i8)") +    def is_ok(A, F, x, k): -    ok = 10**16 -    ng = -1 -    while ok - ng > 1: -        mid = (ok + ng) // 2 -        if is_ok(mid): -            ok = mid -        else: -            ng = mid -    return ok +    cc.compile() +    exit(0) +from my_module import is_ok - -print((solve(np.fromstring(open(0).read(), dtype=np.int64, sep=" ")))) +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] +ok = 10**16 +ng = -1 +while ok - ng > 1: +    mid = (ok + ng) // 2 +    if is_ok(A, F, mid, k): +        ok = mid +    else: +        ng = mid +print(ok)