結果
問題 | No.10 +か×か |
ユーザー | penqen |
提出日時 | 2021-04-05 14:39:16 |
言語 | Elixir (1.16.2) |
結果 |
MLE
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 1,054 ms |
コンパイル使用メモリ | 55,552 KB |
実行使用メモリ | 826,192 KB |
最終ジャッジ日時 | 2023-08-30 01:22:12 |
合計ジャッジ時間 | 7,456 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 558 ms
49,248 KB |
testcase_01 | AC | 556 ms
49,480 KB |
testcase_02 | AC | 546 ms
49,768 KB |
testcase_03 | AC | 590 ms
68,064 KB |
testcase_04 | MLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
コンパイルメッセージ
warning: use Bitwise is deprecated. import Bitwise instead Main.exs:2: Main
ソースコード
defmodule Main do use Bitwise, only_operators: true def main do n = IO.read(:line) |> String.trim() |> String.to_integer() total = IO.read(:line) |> String.trim() |> String.to_integer() [a | an] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) an |> Enum.reverse() |> Enum.with_index(0) |> Enum.reduce(Map.put(%{}, total, [0]), fn {a, i}, dp -> Enum.reduce(dp, %{}, fn {rest, wi}, ndp -> ndp = if :math.fmod(rest, a) == 0, do: Map.update(ndp, div(rest, a), wi, fn q -> wi ++ q end), else: ndp if a <= rest do wi = Enum.map(wi, fn w -> w + (1 <<< i) end) Map.update(ndp, rest - a, wi, fn q -> wi ++ q end) else ndp end end) end) |> Map.get(a) |> Enum.max() |> restore(n) |> Enum.reverse() |> Enum.join("") |> IO.puts() end def restore(_w, 1), do: [] def restore(w, i), do: [(if (w &&& 1) == 1, do: :+, else: :*) | restore(w >>> 1 ,i - 1)] end