defmodule Main do def main do 1..3 |> Enum.map(fn _ -> IO.read(:line) |> String.trim() end) |> solve |> IO.puts() end defp solve([l, _, w]) do solve_rec( w |> String.split() |> Enum.map(&String.to_integer/1) |> Enum.sort(), 0, l |> String.to_integer() ) end defp solve_rec(w, c, n) do cond do w |> Enum.empty?() || n < w |> hd -> c true -> solve_rec(w |> Enum.slice(1..-1), c + 1, n - (w |> hd)) end end end