結果

問題 No.791 うし数列
ユーザー gemmarogemmaro
提出日時 2020-04-16 20:13:30
言語 Elixir
(1.16.2)
結果
AC  
実行時間 623 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 993 ms
コンパイル使用メモリ 55,880 KB
実行使用メモリ 50,480 KB
最終ジャッジ日時 2023-08-30 00:16:17
合計ジャッジ時間 12,865 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 598 ms
49,972 KB
testcase_01 AC 585 ms
49,880 KB
testcase_02 AC 608 ms
49,304 KB
testcase_03 AC 605 ms
49,828 KB
testcase_04 AC 604 ms
49,868 KB
testcase_05 AC 604 ms
49,384 KB
testcase_06 AC 590 ms
49,300 KB
testcase_07 AC 596 ms
49,288 KB
testcase_08 AC 608 ms
49,332 KB
testcase_09 AC 620 ms
49,260 KB
testcase_10 AC 617 ms
50,480 KB
testcase_11 AC 623 ms
49,812 KB
testcase_12 AC 608 ms
49,184 KB
testcase_13 AC 603 ms
49,364 KB
testcase_14 AC 615 ms
49,340 KB
testcase_15 AC 609 ms
49,052 KB
testcase_16 AC 596 ms
49,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    IO.read(:line)
    |> String.trim()
    |> solve
    |> IO.puts()
  end

  defp solve(n) do
    n
    |> String.slice(1..-1)
    |> (fn o ->
          s = o |> String.length()
          t = o |> String.to_charlist() |> Enum.count(&(&1 == ?3))

          cond do
            n |> String.first() != "1" || s != t || t == 0 -> -1
            true -> s
          end
        end).()
  end
end
0