defmodule Main do def input, do: IO.read(:line) |> String.trim def ii, do: input() |> String.to_integer def li, do: input() |> String.split |> Enum.map(&String.to_integer/1) def yn(b), do: IO.puts(if b, do: "Yes", else: "No") @inf 10 ** 12 def main do [n, d] = li() xs = li() vs = li() ans = bsearch(@inf, 0, @inf, n, d, xs, vs) IO.puts ans end def f(t, vs) do Enum.map(vs, fn v -> v * t end) |> Enum.sum end def bsearch(res, lo, hi, n, d, xs, vs) do if lo > hi do res else m = div(lo + hi, 2) s = f(m, vs) if s >= d do bsearch(min(res, m), lo, m-1, n, d, xs, vs) else bsearch(res, m+1, hi, n, d, xs, vs) end end end end