結果

問題 No.279 木の数え上げ
ユーザー gemmarogemmaro
提出日時 2020-04-19 22:46:53
言語 Elixir
(1.16.2)
結果
AC  
実行時間 1,047 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 1,259 ms
コンパイル使用メモリ 55,868 KB
実行使用メモリ 50,632 KB
最終ジャッジ日時 2023-08-30 00:34:16
合計ジャッジ時間 19,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 613 ms
49,040 KB
testcase_01 AC 612 ms
49,420 KB
testcase_02 AC 613 ms
49,236 KB
testcase_03 AC 614 ms
49,116 KB
testcase_04 AC 616 ms
49,772 KB
testcase_05 AC 620 ms
49,324 KB
testcase_06 AC 619 ms
48,964 KB
testcase_07 AC 616 ms
49,360 KB
testcase_08 AC 622 ms
49,188 KB
testcase_09 AC 612 ms
50,352 KB
testcase_10 AC 1,013 ms
50,500 KB
testcase_11 AC 713 ms
49,188 KB
testcase_12 AC 883 ms
49,880 KB
testcase_13 AC 661 ms
49,560 KB
testcase_14 AC 1,047 ms
50,348 KB
testcase_15 AC 968 ms
49,972 KB
testcase_16 AC 943 ms
49,952 KB
testcase_17 AC 1,010 ms
50,076 KB
testcase_18 AC 804 ms
50,036 KB
testcase_19 AC 1,008 ms
50,632 KB
testcase_20 AC 1,034 ms
50,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    input_solve()
    |> IO.puts()
  end

  def input_solve() do
    input_solve_rec([0, 0, 0])
    |> (fn [a, b, c] -> [a, b, c |> div(2)] end).()
    |> Enum.min()
  end

  def input_solve_rec(result) do
    case IO.read(1000) do
      :eof -> result
      s -> input_solve_rec(count_tre(s |> String.to_charlist(), result))
    end
  end

  defp count_tre([], [t, r, e]) do
    [t, r, e]
  end

  defp count_tre(s, [t, r, e]) do
    tl(s)
    |> count_tre(
      cond do
        hd(s) == ?t -> [t + 1, r, e]
        hd(s) == ?r -> [t, r + 1, e]
        hd(s) == ?e -> [t, r, e + 1]
        true -> [t, r, e]
      end
    )
  end
end
0