結果

問題 No.345 最小チワワ問題
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-12 19:04:40
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 72,364 KB
実行使用メモリ 56,200 KB
最終ジャッジ日時 2023-08-17 03:45:07
合計ジャッジ時間 7,168 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,696 KB
testcase_01 AC 115 ms
55,748 KB
testcase_02 AC 116 ms
55,712 KB
testcase_03 AC 117 ms
55,908 KB
testcase_04 AC 119 ms
55,604 KB
testcase_05 AC 114 ms
56,036 KB
testcase_06 AC 115 ms
55,812 KB
testcase_07 AC 116 ms
55,832 KB
testcase_08 AC 118 ms
55,904 KB
testcase_09 AC 119 ms
55,864 KB
testcase_10 AC 116 ms
55,468 KB
testcase_11 AC 120 ms
55,984 KB
testcase_12 WA -
testcase_13 AC 118 ms
56,068 KB
testcase_14 AC 119 ms
55,988 KB
testcase_15 AC 119 ms
56,200 KB
testcase_16 AC 119 ms
55,620 KB
testcase_17 AC 114 ms
55,624 KB
testcase_18 AC 115 ms
55,952 KB
testcase_19 AC 115 ms
55,568 KB
testcase_20 AC 120 ms
55,600 KB
testcase_21 WA -
testcase_22 AC 117 ms
55,904 KB
testcase_23 AC 116 ms
53,972 KB
testcase_24 AC 117 ms
56,168 KB
testcase_25 AC 115 ms
55,576 KB
testcase_26 AC 115 ms
55,628 KB
testcase_27 AC 115 ms
55,872 KB
testcase_28 WA -
testcase_29 AC 115 ms
55,792 KB
testcase_30 AC 115 ms
55,980 KB
testcase_31 AC 113 ms
56,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int a = S.indexOf("c");
        int min = Integer.MAX_VALUE;
        if(a==-1){
            System.out.println(-1);
        }else{
            while(a!=-1){
                S = S.substring(a+1);
                int b = S.indexOf("w");
                String t = S.substring(b+1);
                int c = t.indexOf("w");
                if(c!=-1 && min>b+c+3){
                    min = b+c+3;
                }
                a = S.indexOf("c");
            }
            System.out.println(min);
        }
    }
}
0