import os,io

input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

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

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

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

a.sort()

a.reverse()

f.sort()

maxproduct=0

for i in range(n):

  maxproduct=max(f[i]*a[i],maxproduct)

l1=0

r1=maxproduct

while True:

  l2=l1

  r2=(l1+r1)//2

  if l2==r2:

    break

  counter=0

  for i in range(n):

    c=r2//f[i]

    while (c+1)*f[i]<=r2:

      c+=1

    counter+=max(0,a[i]-c)

  if counter<=k:

    r1=r2

  else:

    l1=r2

if l1==r1:

  print(r2)

else:

  counter=0

  r2=l1

  for i in range(n):

    c=r2//f[i]

    while (c+1)*f[i]<=r2:

      c+=1

    counter+=max(0,a[i]-c)

  if counter<=k:

    print(l1)

  else:

    print(r1)
import sys

import os,io

input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

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

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

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

a.sort()

f.sort()

f.reverse()

if sum(a)<=k:

  print((0))

  sys.exit()

pointer=0

l=0

r=0

for i in range(n):

  r=max(r,a[i]*f[i])

while l+1<r:

  try1=(r+l)//2

  required=0

  for i in range(n):

    required+=(max(0,a[i]-try1//f[i]))

  if required>k:

    l=try1

  else:

    r=try1

required=0

for i in range(n):

  required+=(max(0,a[i]-l//f[i]))

if required>k:

  print(r)

else:

  print(l)
import os, io

input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
a.reverse()
f.sort()
maxproduct = 0
for i in range(n):
    maxproduct = max(f[i] * a[i], maxproduct)
l1 = 0
r1 = maxproduct
while True:
    l2 = l1
    r2 = (l1 + r1) // 2
    if l2 == r2:
        break
    counter = 0
    for i in range(n):
        c = r2 // f[i]
        while (c + 1) * f[i] <= r2:
            c += 1
        counter += max(0, a[i] - c)
    if counter <= k:
        r1 = r2
    else:
        l1 = r2
if l1 == r1:
    print(r2)
else:
    counter = 0
    r2 = l1
    for i in range(n):
        c = r2 // f[i]
        while (c + 1) * f[i] <= r2:
            c += 1
        counter += max(0, a[i] - c)
    if counter <= k:
        print(l1)
    else:
        print(r1)

import sys
import os, io

input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort()
f.reverse()
if sum(a) <= k:
    print((0))
    sys.exit()
pointer = 0
l = 0
r = 0
for i in range(n):
    r = max(r, a[i] * f[i])
while l + 1 < r:
    try1 = (r + l) // 2
    required = 0
    for i in range(n):
        required += max(0, a[i] - try1 // f[i])
    if required > k:
        l = try1
    else:
        r = try1
required = 0
for i in range(n):
    required += max(0, a[i] - l // f[i])
if required > k:
    print(r)
else:
    print(l)

+import sys -a.reverse() -maxproduct = 0 +f.reverse() +if sum(a) <= k: +    print((0)) +    sys.exit() +pointer = 0 +l = 0 +r = 0 -    maxproduct = max(f[i] * a[i], maxproduct) -l1 = 0 -r1 = maxproduct -while True: -    l2 = l1 -    r2 = (l1 + r1) // 2 -    if l2 == r2: -        break -    counter = 0 +    r = max(r, a[i] * f[i]) +while l + 1 < r: +    try1 = (r + l) // 2 +    required = 0 -        c = r2 // f[i] -        while (c + 1) * f[i] <= r2: -            c += 1 -        counter += max(0, a[i] - c) -    if counter <= k: -        r1 = r2 +        required += max(0, a[i] - try1 // f[i]) +    if required > k: +        l = try1 -        l1 = r2 -if l1 == r1: -    print(r2) +        r = try1 +required = 0 +for i in range(n): +    required += max(0, a[i] - l // f[i]) +if required > k: +    print(r) -    counter = 0 -    r2 = l1 -    for i in range(n): -        c = r2 // f[i] -        while (c + 1) * f[i] <= r2: -            c += 1 -        counter += max(0, a[i] - c) -    if counter <= k: -        print(l1) -    else: -        print(r1) +    print(l)