結果

問題 No.5 数字のブロック
ユーザー asatakeasatake
提出日時 2018-08-12 11:48:45
言語 Elixir
(1.16.2)
結果
RE  
実行時間 -
コード長 444 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 55,212 KB
実行使用メモリ 52,484 KB
最終ジャッジ日時 2023-08-29 22:52:22
合計ジャッジ時間 26,272 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 638 ms
49,700 KB
testcase_01 AC 647 ms
49,136 KB
testcase_02 RE -
testcase_03 AC 639 ms
50,420 KB
testcase_04 AC 655 ms
49,728 KB
testcase_05 AC 659 ms
51,280 KB
testcase_06 AC 638 ms
50,028 KB
testcase_07 AC 641 ms
49,800 KB
testcase_08 AC 635 ms
50,428 KB
testcase_09 AC 643 ms
49,864 KB
testcase_10 AC 662 ms
50,700 KB
testcase_11 AC 646 ms
49,864 KB
testcase_12 AC 671 ms
50,180 KB
testcase_13 AC 674 ms
51,176 KB
testcase_14 AC 671 ms
49,352 KB
testcase_15 AC 664 ms
49,112 KB
testcase_16 AC 664 ms
50,456 KB
testcase_17 AC 656 ms
51,144 KB
testcase_18 AC 646 ms
50,380 KB
testcase_19 AC 654 ms
51,744 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 673 ms
49,156 KB
testcase_24 AC 660 ms
49,164 KB
testcase_25 AC 649 ms
49,804 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 664 ms
49,876 KB
testcase_30 AC 658 ms
49,980 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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