結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2016-02-27 17:19:50 |
言語 | Scala(Beta) (3.6.2) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 609 bytes |
コンパイル時間 | 9,677 ms |
コンパイル使用メモリ | 275,300 KB |
実行使用メモリ | 157,328 KB |
最終ジャッジ日時 | 2025-03-30 08:53:28 |
合計ジャッジ時間 | 16,321 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 28 |
ソースコード
object Main { def solve(s: String): Int = { val n = s.length var answer, w1, w2 = Int.MaxValue for (idx <- (n - 1) to 0 by -1) { if (s(idx) == 'w') { w2 = w1 w1 = idx } else if (s(idx) == 'c' && w2 < Int.MaxValue) { answer = scala.math.min(answer, w2 - idx + 1) } } if (answer < Int.MaxValue) { return answer } else { return -1 } } def main(args: Array[String]): Unit = { println(solve(scala.io.StdIn.readLine())) } }