結果

問題 No.345 最小チワワ問題
ユーザー noriocnorioc
提出日時 2016-02-27 08:58:05
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,009 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 12,302 ms
コンパイル使用メモリ 254,936 KB
実行使用メモリ 63,300 KB
最終ジャッジ日時 2023-09-02 06:40:34
合計ジャッジ時間 47,396 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 963 ms
62,576 KB
testcase_01 AC 958 ms
62,792 KB
testcase_02 AC 953 ms
63,124 KB
testcase_03 AC 981 ms
62,664 KB
testcase_04 AC 965 ms
62,744 KB
testcase_05 AC 983 ms
62,656 KB
testcase_06 AC 985 ms
62,800 KB
testcase_07 AC 984 ms
63,020 KB
testcase_08 AC 990 ms
62,844 KB
testcase_09 AC 979 ms
62,652 KB
testcase_10 AC 990 ms
62,924 KB
testcase_11 AC 985 ms
62,848 KB
testcase_12 AC 1,009 ms
62,704 KB
testcase_13 AC 996 ms
63,000 KB
testcase_14 AC 993 ms
62,740 KB
testcase_15 AC 993 ms
62,884 KB
testcase_16 AC 999 ms
62,684 KB
testcase_17 AC 976 ms
62,896 KB
testcase_18 AC 984 ms
62,912 KB
testcase_19 AC 975 ms
62,812 KB
testcase_20 AC 961 ms
62,800 KB
testcase_21 AC 968 ms
62,828 KB
testcase_22 AC 963 ms
62,700 KB
testcase_23 AC 973 ms
62,672 KB
testcase_24 AC 966 ms
63,120 KB
testcase_25 AC 968 ms
63,092 KB
testcase_26 AC 969 ms
62,680 KB
testcase_27 AC 968 ms
62,984 KB
testcase_28 AC 980 ms
62,788 KB
testcase_29 AC 964 ms
63,300 KB
testcase_30 AC 975 ms
62,968 KB
testcase_31 AC 966 ms
62,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math._

object Main {
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val s = sc.next

    val reg = "c.*?w.*?w".r
    var ans = Integer.MAX_VALUE
    for (i <- 0 to s.length-1 if s(i) == 'c') {
      reg.findFirstIn(s.substring(i)) match {
        case Some(v) => ans = min(ans, v.length)
        case _ =>
      }
    }

    if (ans == Integer.MAX_VALUE)
      println(-1)
    else
      println(ans)
  }
}
0