let rec lower_bound l r p =
  if r <= 1 + l
  then r
  else let m = (l + r) / 2 in
       if p m
       then lower_bound l m p
       else lower_bound m r p

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let fs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun f -> f in
  Array.sort compare as_;
  Array.sort (fun f f' -> compare f' f) fs;
  Printf.printf "%d\n" @@
  lower_bound (-1) 1000000000001 @@ fun cost ->
    ( >= ) k @@
    Array.fold_left ( + ) 0 @@
    Array.init n @@ fun i ->
      max 0 (fs.(i) * as_.(i) - cost + fs.(i) - 1) / fs.(i)
