結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2016-02-27 08:58:05 |
| 言語 | Scala(Beta) (3.6.2) |
| 結果 |
AC
|
| 実行時間 | 986 ms / 2,000 ms |
| コード長 | 454 bytes |
| コンパイル時間 | 10,650 ms |
| コンパイル使用メモリ | 251,168 KB |
| 実行使用メモリ | 63,744 KB |
| 最終ジャッジ日時 | 2024-06-11 13:32:16 |
| 合計ジャッジ時間 | 39,813 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
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)
}
}
norioc