結果

問題 No.5 数字のブロック
ユーザー gemmarogemmaro
提出日時 2020-04-17 08:59:08
言語 Elixir
(1.16.2)
結果
AC  
実行時間 643 ms / 5,000 ms
コード長 516 bytes
コンパイル時間 1,059 ms
コンパイル使用メモリ 54,712 KB
実行使用メモリ 51,932 KB
最終ジャッジ日時 2023-08-30 00:18:53
合計ジャッジ時間 24,441 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 619 ms
49,236 KB
testcase_01 AC 620 ms
49,300 KB
testcase_02 AC 629 ms
49,904 KB
testcase_03 AC 629 ms
50,336 KB
testcase_04 AC 637 ms
50,284 KB
testcase_05 AC 638 ms
51,012 KB
testcase_06 AC 636 ms
50,236 KB
testcase_07 AC 634 ms
50,308 KB
testcase_08 AC 640 ms
50,308 KB
testcase_09 AC 633 ms
49,320 KB
testcase_10 AC 639 ms
50,364 KB
testcase_11 AC 641 ms
49,792 KB
testcase_12 AC 636 ms
50,184 KB
testcase_13 AC 643 ms
51,244 KB
testcase_14 AC 607 ms
49,844 KB
testcase_15 AC 631 ms
49,964 KB
testcase_16 AC 616 ms
50,588 KB
testcase_17 AC 640 ms
51,932 KB
testcase_18 AC 643 ms
50,520 KB
testcase_19 AC 637 ms
51,176 KB
testcase_20 AC 622 ms
49,232 KB
testcase_21 AC 627 ms
49,812 KB
testcase_22 AC 630 ms
49,692 KB
testcase_23 AC 630 ms
49,920 KB
testcase_24 AC 632 ms
50,076 KB
testcase_25 AC 637 ms
49,348 KB
testcase_26 AC 617 ms
49,472 KB
testcase_27 AC 632 ms
49,132 KB
testcase_28 AC 619 ms
49,456 KB
testcase_29 AC 636 ms
50,240 KB
testcase_30 AC 634 ms
49,448 KB
testcase_31 AC 634 ms
49,380 KB
testcase_32 AC 625 ms
49,396 KB
testcase_33 AC 629 ms
49,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0