結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2018-08-12 11:57:09 |
| 言語 | Elixir (1.18.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 518 bytes |
| コンパイル時間 | 1,110 ms |
| コンパイル使用メモリ | 62,456 KB |
| 実行使用メモリ | 59,056 KB |
| 最終ジャッジ日時 | 2024-12-31 02:10:50 |
| 合計ジャッジ時間 | 21,555 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 24 |
コンパイルメッセージ
warning: the result of evaluating operator '+'/2 is ignored (suppress the warning by assigning the expression to the _ variable)
│
20 │ true -> Enum.count(t) + 1
│ ~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ Main.exs:20
ソースコード
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