結果

問題 No.5 数字のブロック
ユーザー asatakeasatake
提出日時 2018-08-12 11:57:09
言語 Elixir
(1.16.2)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 1,380 ms
コンパイル使用メモリ 54,312 KB
実行使用メモリ 52,044 KB
最終ジャッジ日時 2023-08-29 22:50:20
合計ジャッジ時間 25,630 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 638 ms
49,932 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 635 ms
49,356 KB
testcase_21 AC 634 ms
49,316 KB
testcase_22 AC 641 ms
49,540 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 647 ms
49,788 KB
testcase_27 AC 651 ms
49,252 KB
testcase_28 AC 644 ms
49,420 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 646 ms
49,928 KB
testcase_32 AC 644 ms
49,564 KB
testcase_33 AC 663 ms
50,172 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: the result of evaluating operator '+'/2 is ignored (suppress the warning by assigning the expression to the _ variable)
  Main.exs:20

ソースコード

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, w, l) do
    if Enum.count(w) > 0 do
      h = hd w
      t = tl w
      cond do
        c + h <= l -> calc(c + h, t, l)
        true -> Enum.count(t) + 1
      end
    end
    0
  end

end
0