import sys

sys.setrecursionlimit(10 ** 7)





def main():

    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)



    l = -1

    r = 10 ** 13



    def test(x):

        cnt = 0

        for ae, fe in zip(a, f):

            cnt += max(0, ae - x // fe)



        return cnt <= k



    while l + 1 < r:

        m = (l + r) // 2

        if test(m):

            r = m

        else:

            l = m



    ans = r

    print(ans)





if __name__ == "__main__":

    main()

import sys

sys.setrecursionlimit(10 ** 7)



import numpy as np





def main():

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

    a = np.array(input().split(), np.int64)

    f = np.array(input().split(), np.int64)



    a.sort()

    f.sort()

    f = f[::-1]



    l = -1

    r = 10 ** 13



    def test(x):

        cnt = np.maximum(0, a - x // f).sum()

        return cnt <= k



    while l + 1 < r:

        m = (l + r) // 2

        if test(m):

            r = m

        else:

            l = m



    ans = r

    print(ans)





if __name__ == "__main__":

    main()

import sys

sys.setrecursionlimit(10**7)


def main():
    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)
    l = -1
    r = 10**13

    def test(x):
        cnt = 0
        for ae, fe in zip(a, f):
            cnt += max(0, ae - x // fe)
        return cnt <= k

    while l + 1 < r:
        m = (l + r) // 2
        if test(m):
            r = m
        else:
            l = m
    ans = r
    print(ans)


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(10**7)
import numpy as np


def main():
    n, k = list(map(int, input().split()))
    a = np.array(input().split(), np.int64)
    f = np.array(input().split(), np.int64)
    a.sort()
    f.sort()
    f = f[::-1]
    l = -1
    r = 10**13

    def test(x):
        cnt = np.maximum(0, a - x // f).sum()
        return cnt <= k

    while l + 1 < r:
        m = (l + r) // 2
        if test(m):
            r = m
        else:
            l = m
    ans = r
    print(ans)


if __name__ == "__main__":
    main()

+import numpy as np -    a = list(map(int, input().split())) -    f = list(map(int, input().split())) +    a = np.array(input().split(), np.int64) +    f = np.array(input().split(), np.int64) -    f.sort(reverse=True) +    f.sort() +    f = f[::-1] -        cnt = 0 -        for ae, fe in zip(a, f): -            cnt += max(0, ae - x // fe) +        cnt = np.maximum(0, a - x // f).sum()