結果

問題 No.965 門松列が嫌い
ユーザー daikiyamanedaikiyamane
提出日時 2020-01-27 00:09:15
言語 Elixir
(1.16.2)
結果
TLE  
実行時間 -
コード長 971 bytes
コンパイル時間 1,097 ms
コンパイル使用メモリ 56,320 KB
実行使用メモリ 56,864 KB
最終ジャッジ日時 2023-08-29 23:47:51
合計ジャッジ時間 6,259 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 615 ms
50,124 KB
testcase_01 AC 616 ms
49,484 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  #入力
  def main do
    num = IO.gets("") |> String.trim |> String.split |>Enum.map(&String.to_integer/1)
    check(num, 0)
  end
  # 大 小 中
  def check([a, b, c], cun) when a > b and a > c do
    if (a-c) < (c-b) do
      check([a-1, b, c], cun+1)
    else
      check([a, b, c-1], cun+1)
    end
  end
  # 中 小 大
  def check([a, b, c], cun) when a > b and a < c  do
    if (c-a) < (a-b) do
      check([a, b, c-1], cun+1)
    else
      check([a-1, b, c], cun+1)
    end
  end
  # 中 大 小
  def check([a, b, c], cun) when a > c and a < b do
    if (b-a) < (a-c) do
      check([a, b-1, c], cun+1)
    else
      check([a-1, b, c], cun+1)
    end
  end
  # 小 大 中
  def check([a, b, c], cun) when a < c and c < b do
      if (c-a) < (b-c) do
        check([a, b, c-1], cun+1)
      else
        check([a, b-1, c], cun+1)
      end
  end
  def check([a, b, c], cun) when a == b or a == c or b == c  do
    IO.inspect cun
  end
end
0