結果

問題 No.5 数字のブロック
ユーザー 3qvwn3qvwn
提出日時 2019-07-01 23:48:15
言語 Elixir
(1.16.2)
結果
AC  
実行時間 636 ms / 5,000 ms
コード長 459 bytes
コンパイル時間 1,029 ms
コンパイル使用メモリ 54,876 KB
実行使用メモリ 51,968 KB
最終ジャッジ日時 2023-08-29 23:30:40
合計ジャッジ時間 24,520 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 606 ms
49,168 KB
testcase_01 AC 605 ms
49,184 KB
testcase_02 AC 608 ms
49,232 KB
testcase_03 AC 614 ms
50,868 KB
testcase_04 AC 617 ms
50,276 KB
testcase_05 AC 621 ms
50,536 KB
testcase_06 AC 622 ms
49,892 KB
testcase_07 AC 621 ms
50,324 KB
testcase_08 AC 626 ms
50,292 KB
testcase_09 AC 629 ms
49,392 KB
testcase_10 AC 632 ms
50,540 KB
testcase_11 AC 620 ms
49,656 KB
testcase_12 AC 619 ms
50,656 KB
testcase_13 AC 615 ms
50,500 KB
testcase_14 AC 614 ms
49,960 KB
testcase_15 AC 615 ms
49,356 KB
testcase_16 AC 626 ms
50,724 KB
testcase_17 AC 626 ms
51,968 KB
testcase_18 AC 622 ms
51,164 KB
testcase_19 AC 613 ms
51,172 KB
testcase_20 AC 611 ms
49,480 KB
testcase_21 AC 613 ms
50,152 KB
testcase_22 AC 619 ms
49,700 KB
testcase_23 AC 618 ms
49,100 KB
testcase_24 AC 616 ms
49,112 KB
testcase_25 AC 600 ms
49,552 KB
testcase_26 AC 614 ms
49,712 KB
testcase_27 AC 604 ms
49,956 KB
testcase_28 AC 601 ms
49,104 KB
testcase_29 AC 619 ms
50,172 KB
testcase_30 AC 618 ms
49,188 KB
testcase_31 AC 622 ms
49,688 KB
testcase_32 AC 621 ms
49,212 KB
testcase_33 AC 636 ms
49,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    l = IO.gets("") |> String.trim |> String.to_integer
    _ = IO.gets("")
    w = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer(&1)) |> Enum.sort
    sum(w, 0, l, 0) |> IO.puts
  end
  
  def sum([], _, _, count) do
   count
  end
  
  def sum([head | tail], total, l, count) when total+head <= l do
    sum(tail, total + head, l, count+1)
  end
  
  def sum(_, _, _, count) do
    count
  end
end
0