結果

問題 No.345 最小チワワ問題
ユーザー gemmarogemmaro
提出日時 2020-04-18 21:18:25
言語 Elixir
(1.16.2)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 1,338 ms
コンパイル使用メモリ 54,592 KB
実行使用メモリ 51,128 KB
最終ジャッジ日時 2023-08-30 00:25:19
合計ジャッジ時間 23,536 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 625 ms
49,720 KB
testcase_01 AC 625 ms
49,112 KB
testcase_02 AC 616 ms
49,864 KB
testcase_03 AC 610 ms
49,108 KB
testcase_04 AC 623 ms
49,344 KB
testcase_05 AC 613 ms
51,128 KB
testcase_06 AC 612 ms
48,988 KB
testcase_07 AC 606 ms
49,212 KB
testcase_08 AC 613 ms
49,276 KB
testcase_09 AC 601 ms
50,180 KB
testcase_10 AC 616 ms
49,168 KB
testcase_11 AC 621 ms
49,160 KB
testcase_12 AC 632 ms
50,000 KB
testcase_13 AC 617 ms
50,120 KB
testcase_14 AC 627 ms
49,852 KB
testcase_15 AC 623 ms
49,760 KB
testcase_16 AC 620 ms
49,372 KB
testcase_17 AC 622 ms
49,180 KB
testcase_18 AC 624 ms
50,008 KB
testcase_19 AC 614 ms
49,836 KB
testcase_20 AC 626 ms
47,900 KB
testcase_21 AC 637 ms
49,292 KB
testcase_22 AC 640 ms
48,076 KB
testcase_23 AC 612 ms
50,016 KB
testcase_24 AC 607 ms
49,192 KB
testcase_25 AC 617 ms
49,196 KB
testcase_26 AC 639 ms
49,880 KB
testcase_27 AC 618 ms
49,192 KB
testcase_28 AC 619 ms
49,464 KB
testcase_29 AC 621 ms
50,160 KB
testcase_30 AC 609 ms
49,728 KB
testcase_31 AC 610 ms
49,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

  def solve(s) do
    t = [
      s |> String.length()
      | Regex.scan(~r/(?=(c[^cw]*?w[^w]*?w))/, s)
        |> Enum.map(fn [_, x] -> x |> String.length() end)
    ]

    cond do
      t |> length == 1 -> -1
      true -> t |> Enum.min()
    end
  end
end
0