from numpy import*

k,A,F=[int64(t.split())for t in open(0)]

l=-1

r=10**12

while~l+r:

 m=l+r>>1

 if sum(A-minimum(sort(A),m//sort(F)[::-1]))>k[1]:l=m

 else:r=m

print(r)
(_,k),*t=[list(map(int,t.split()))for t in open(0)]

A,F=list(map(sorted,t))

o=10**12

g=-1

while~g+o:

 m,l=o+g>>1,k

 for a,f in zip(A,F[::-1]):l-=max(0,a-m//f)

 if l<0:g=m

 else:o=m

print(o)
from numpy import *

k, A, F = [int64(t.split()) for t in open(0)]
l = -1
r = 10**12
while ~l + r:
    m = l + r >> 1
    if sum(A - minimum(sort(A), m // sort(F)[::-1])) > k[1]:
        l = m
    else:
        r = m
print(r)

(_, k), *t = [list(map(int, t.split())) for t in open(0)]
A, F = list(map(sorted, t))
o = 10**12
g = -1
while ~g + o:
    m, l = o + g >> 1, k
    for a, f in zip(A, F[::-1]):
        l -= max(0, a - m // f)
    if l < 0:
        g = m
    else:
        o = m
print(o)

-from numpy import * - -k, A, F = [int64(t.split()) for t in open(0)] -l = -1 -r = 10**12 -while ~l + r: -    m = l + r >> 1 -    if sum(A - minimum(sort(A), m // sort(F)[::-1])) > k[1]: -        l = m +(_, k), *t = [list(map(int, t.split())) for t in open(0)] +A, F = list(map(sorted, t)) +o = 10**12 +g = -1 +while ~g + o: +    m, l = o + g >> 1, k +    for a, f in zip(A, F[::-1]): +        l -= max(0, a - m // f) +    if l < 0: +        g = m -        r = m -print(r) +        o = m +print(o)