



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

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

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

A.sort(reverse = True)

F.sort()



max_f = A[0] * F[-1]



def binary_search(min_f, max_f):

	if min_f == max_f:

		return min_f



	mid_f = min_f + (max_f - min_f)//2

	tmp = 0

	for i in range(N):

		tmp += max(0,A[i] - mid_f // F[i])

	

	if tmp <= K:

		return binary_search(min_f, mid_f)

	else:

		return binary_search(mid_f+1, max_f)



print((binary_search(0, max_f)))
import numpy as np

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines



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

A = np.array(list(map(int, input().split())), dtype = np.int64)

F = np.array(list(map(int, input().split())), dtype = np.int64)

A.sort()

F.sort()

F = F[::-1]



l = 0

r = 10**12 + 100



def solve(num):

	B = num // F

	tmp = np.sum(np.maximum(0, A - B))

	if tmp <= K:

		return 1

	else:

		return 0



while r - l > 1:

	mid = (l + r) // 2

	if solve(mid):

		r = mid

	else:

		l = mid



if solve(l):

	print(l)

else:

	print(r)



N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort(reverse=True)
F.sort()
max_f = A[0] * F[-1]


def binary_search(min_f, max_f):
    if min_f == max_f:
        return min_f
    mid_f = min_f + (max_f - min_f) // 2
    tmp = 0
    for i in range(N):
        tmp += max(0, A[i] - mid_f // F[i])
    if tmp <= K:
        return binary_search(min_f, mid_f)
    else:
        return binary_search(mid_f + 1, max_f)


print((binary_search(0, max_f)))

import numpy as np
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())), dtype=np.int64)
F = np.array(list(map(int, input().split())), dtype=np.int64)
A.sort()
F.sort()
F = F[::-1]
l = 0
r = 10**12 + 100


def solve(num):
    B = num // F
    tmp = np.sum(np.maximum(0, A - B))
    if tmp <= K:
        return 1
    else:
        return 0


while r - l > 1:
    mid = (l + r) // 2
    if solve(mid):
        r = mid
    else:
        l = mid
if solve(l):
    print(l)
else:
    print(r)

+import numpy as np +import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines -A = list(map(int, input().split())) -F = list(map(int, input().split())) -A.sort(reverse=True) +A = np.array(list(map(int, input().split())), dtype=np.int64) +F = np.array(list(map(int, input().split())), dtype=np.int64) +A.sort() -max_f = A[0] * F[-1] +F = F[::-1] +l = 0 +r = 10**12 + 100 -def binary_search(min_f, max_f): -    if min_f == max_f: -        return min_f -    mid_f = min_f + (max_f - min_f) // 2 -    tmp = 0 -    for i in range(N): -        tmp += max(0, A[i] - mid_f // F[i]) +def solve(num): +    B = num // F +    tmp = np.sum(np.maximum(0, A - B)) -        return binary_search(min_f, mid_f) +        return 1 -        return binary_search(mid_f + 1, max_f) +        return 0 -print((binary_search(0, max_f))) +while r - l > 1: +    mid = (l + r) // 2 +    if solve(mid): +        r = mid +    else: +        l = mid +if solve(l): +    print(l) +else: +    print(r)