結果

問題 No.5 数字のブロック
ユーザー asatakeasatake
提出日時 2018-08-12 12:07:10
言語 Elixir
(1.16.2)
結果
AC  
実行時間 685 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 55,564 KB
実行使用メモリ 51,792 KB
最終ジャッジ日時 2023-08-29 22:53:13
合計ジャッジ時間 25,748 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 665 ms
49,120 KB
testcase_01 AC 657 ms
49,304 KB
testcase_02 AC 647 ms
49,248 KB
testcase_03 AC 657 ms
50,444 KB
testcase_04 AC 666 ms
50,332 KB
testcase_05 AC 653 ms
50,544 KB
testcase_06 AC 676 ms
50,396 KB
testcase_07 AC 653 ms
49,764 KB
testcase_08 AC 650 ms
50,780 KB
testcase_09 AC 647 ms
49,932 KB
testcase_10 AC 664 ms
51,080 KB
testcase_11 AC 657 ms
49,864 KB
testcase_12 AC 685 ms
50,196 KB
testcase_13 AC 660 ms
50,608 KB
testcase_14 AC 652 ms
50,444 KB
testcase_15 AC 652 ms
49,232 KB
testcase_16 AC 651 ms
50,456 KB
testcase_17 AC 661 ms
51,064 KB
testcase_18 AC 656 ms
51,268 KB
testcase_19 AC 674 ms
51,792 KB
testcase_20 AC 655 ms
49,772 KB
testcase_21 AC 656 ms
49,316 KB
testcase_22 AC 648 ms
49,868 KB
testcase_23 AC 640 ms
49,416 KB
testcase_24 AC 645 ms
49,296 KB
testcase_25 AC 638 ms
49,360 KB
testcase_26 AC 649 ms
49,760 KB
testcase_27 AC 676 ms
49,340 KB
testcase_28 AC 652 ms
49,328 KB
testcase_29 AC 657 ms
50,220 KB
testcase_30 AC 659 ms
50,068 KB
testcase_31 AC 653 ms
50,236 KB
testcase_32 AC 650 ms
49,828 KB
testcase_33 AC 665 ms
49,372 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable "c" is unused (if the variable is not meant to be used, prefix it with an underscore)
  Main.exs:14: Main.calc/3

warning: variable "l" is unused (if the variable is not meant to be used, prefix it with an underscore)
  Main.exs:14: Main.calc/3

ソースコード

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, [], l) do
    0
  end

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

end
0