program ABC144E_answer
    implicit none
    integer(8)::i,N,K
    integer(8)::C_min=-1
    integer(8)::C_max=0
    integer(8)::C_mid,K_sim
    integer(8),allocatable,dimension(:)::A,F,C

    read(5,*) N,K
    allocate(A(N))
    allocate(F(N))
    allocate(C(N))
    read(5,*) (A(i),i=1,N)
    read(5,*) (F(i),i=1,N)
    A=iqsort(A)
    F=iqsort(F)

    do i=1,N
        C(i)=A(i)*F(N+1-i)

        if(C(i)>C_max)then
            C_max=C(i)
        end if
    end do

    C_max=C_max+1

    do
        K_sim=0
        C_mid=(C_max+C_min)/2
        do i=1,N
            if(mod(max(0,C(i)-C_mid),F(N+1-i))==0)then
                K_sim=K_sim+max(0,C(i)-C_mid)/F(N+1-i)
            else
                K_sim=K_sim+max(0,C(i)-C_mid)/F(N+1-i)+1
            end if
        end do

        if(K_sim>K)then
            C_min=C_mid
        else
            C_max=C_mid
        end if

        if(C_max-C_min<=1) then
            exit
        end if
    end do

    print'(i0)',C_max

contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort    
end program ABC144E_answer