結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー gemmaro
提出日時 2020-05-14 19:01:58
言語 Elixir
(1.18.1)
結果
AC  
実行時間 824 ms / 5,000 ms
コード長 464 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,147 ms
コンパイル使用メモリ 80,600 KB
実行使用メモリ 74,384 KB
最終ジャッジ日時 2025-12-07 12:36:44
合計ジャッジ時間 27,368 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

defmodule Main do
  def main do
    IO.read(:line)
    |> String.trim()
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> solve
    |> IO.puts()
  end

  def solve(rgb) do
    rgb |> solve_rec(0)
  end

  def solve_rec(rgb, x) do
    case rgb |> Enum.sort() do
      [0, 0, 0] -> x
      [0, 0, 1] -> x
      [0, 1, 1] -> x
      [0, b, c] -> [1, b, c - 2] |> solve_rec(x)
      [a, b, c] -> [0, b - a, c - a] |> solve_rec(x + a)
    end
  end
end
0