結果

問題 No.345 最小チワワ問題
ユーザー minokasagominokasago
提出日時 2019-11-01 10:16:28
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 11,755 ms
コンパイル使用メモリ 405,412 KB
実行使用メモリ 53,044 KB
最終ジャッジ日時 2023-10-13 00:37:41
合計ジャッジ時間 22,647 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 283 ms
52,672 KB
testcase_01 AC 281 ms
52,600 KB
testcase_02 AC 283 ms
52,492 KB
testcase_03 AC 280 ms
52,476 KB
testcase_04 AC 279 ms
52,652 KB
testcase_05 AC 280 ms
52,840 KB
testcase_06 AC 281 ms
52,988 KB
testcase_07 AC 279 ms
52,672 KB
testcase_08 AC 277 ms
52,792 KB
testcase_09 AC 280 ms
52,832 KB
testcase_10 AC 281 ms
52,500 KB
testcase_11 AC 281 ms
52,636 KB
testcase_12 AC 281 ms
52,644 KB
testcase_13 AC 282 ms
52,600 KB
testcase_14 AC 284 ms
52,516 KB
testcase_15 AC 281 ms
52,592 KB
testcase_16 AC 280 ms
52,604 KB
testcase_17 AC 281 ms
52,824 KB
testcase_18 AC 282 ms
52,764 KB
testcase_19 AC 281 ms
52,840 KB
testcase_20 AC 283 ms
52,496 KB
testcase_21 AC 279 ms
52,616 KB
testcase_22 AC 280 ms
52,700 KB
testcase_23 AC 281 ms
52,500 KB
testcase_24 AC 280 ms
52,620 KB
testcase_25 AC 282 ms
52,644 KB
testcase_26 AC 285 ms
52,620 KB
testcase_27 AC 282 ms
52,728 KB
testcase_28 AC 285 ms
53,044 KB
testcase_29 AC 285 ms
52,500 KB
testcase_30 AC 279 ms
52,828 KB
testcase_31 AC 277 ms
52,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fun main()
{
    val S = readLine()!!

    var ans = -1

    var pc = 0
    while (pc < S.length) {
        pc = S.indexOf('c', pc);
        if (pc == -1) break;
        var pw = S.indexOf('w', pc + 1)
        if (pw != -1) {
            var pww = S.indexOf('w', pw + 1)
            if (pww != -1) {
                var l = pww - pc + 1
                if (ans == -1 || l < ans) {
                    ans = l
                }
            }
        }
        pc++
    }


    println("${ans}")
}

0