結果

問題 No.999 てん vs. ほむ
ユーザー gemmarogemmaro
提出日時 2020-04-24 08:59:17
言語 Elixir
(1.16.2)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 1,186 ms
コンパイル使用メモリ 55,512 KB
実行使用メモリ 114,056 KB
最終ジャッジ日時 2023-08-30 00:38:41
合計ジャッジ時間 12,998 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 568 ms
49,116 KB
testcase_01 AC 574 ms
49,460 KB
testcase_02 AC 571 ms
49,864 KB
testcase_03 AC 574 ms
50,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 571 ms
49,788 KB
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    IO.read(:line)

    IO.read(:line)
    |> String.trim()
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> solve_rec(0)
    |> IO.puts()
  end

  def solve_rec([], x) do
    x
  end

  def solve_rec(a, x) do
    l = (a |> hd) - (a |> tl |> hd)
    r = (a |> Enum.at(-1)) - (a |> Enum.at(-2))

    cond do
      l < r -> solve_rec(a |> Enum.slice(0..-3), x + r)
      true -> solve_rec(a |> Enum.slice(2..-1), x + l)
    end
  end
end
0