結果

問題 No.345 最小チワワ問題
ユーザー boobrightboobright
提出日時 2016-03-15 00:03:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 75,352 KB
実行使用メモリ 53,372 KB
最終ジャッジ日時 2023-10-26 03:47:45
合計ジャッジ時間 5,380 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
51,352 KB
testcase_01 AC 55 ms
53,348 KB
testcase_02 AC 55 ms
53,360 KB
testcase_03 AC 54 ms
53,356 KB
testcase_04 AC 57 ms
52,312 KB
testcase_05 AC 57 ms
53,364 KB
testcase_06 AC 57 ms
53,360 KB
testcase_07 AC 55 ms
52,260 KB
testcase_08 AC 56 ms
52,292 KB
testcase_09 AC 54 ms
53,356 KB
testcase_10 AC 54 ms
53,352 KB
testcase_11 AC 55 ms
53,360 KB
testcase_12 AC 55 ms
53,364 KB
testcase_13 AC 55 ms
52,260 KB
testcase_14 AC 55 ms
53,364 KB
testcase_15 AC 56 ms
52,288 KB
testcase_16 AC 56 ms
53,364 KB
testcase_17 AC 54 ms
53,360 KB
testcase_18 AC 55 ms
53,364 KB
testcase_19 AC 54 ms
52,260 KB
testcase_20 AC 54 ms
52,284 KB
testcase_21 AC 54 ms
53,352 KB
testcase_22 AC 55 ms
53,360 KB
testcase_23 AC 55 ms
53,372 KB
testcase_24 AC 55 ms
52,276 KB
testcase_25 AC 55 ms
52,276 KB
testcase_26 AC 56 ms
52,264 KB
testcase_27 AC 54 ms
53,352 KB
testcase_28 AC 54 ms
53,356 KB
testcase_29 AC 54 ms
53,352 KB
testcase_30 AC 55 ms
53,356 KB
testcase_31 AC 55 ms
51,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int min = 101;
        int index = 0;
        int index1;
        int index2;
		while ((index1 = line.indexOf("c", index)) != -1) {
        	index2 = line.indexOf("w", index1 + 1);
            if (index2 != -1) {
            	index2 = line.indexOf("w", index2 + 1);
            	if (index2 != -1) {
            		int len = index2 - index1 + 1;
            		if (min > len) {
            			min = len;
            		}
            	}
            }
            index++;
        }
		if (min == 101) {
			System.out.println("-1");
		} else {
			System.out.println(min);
		}
   }
}
0