結果

問題 No.5 数字のブロック
ユーザー asatake
提出日時 2018-08-12 11:48:45
言語 Elixir
(1.18.1)
結果
RE  
実行時間 -
コード長 444 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 64,848 KB
実行使用メモリ 58,512 KB
最終ジャッジ日時 2024-12-31 02:13:07
合計ジャッジ時間 21,849 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main() do
    l = IO.gets("") |> String.trim |> String.to_integer
    n = IO.gets("") |> String.trim |> String.to_integer
    w = IO.gets("")
    |> String.trim
    |> String.split
    |> Enum.map(fn x -> String.to_integer(x) end)
    |> Enum.sort

    IO.inspect n - calc(0, w, l)
  end

  defp calc(c, [h | t], l) do
    cond do
      c + h <= l -> calc(c + h, t, l)
      true -> Enum.count(t) + 1
    end
  end

end
0