結果

問題 No.345 最小チワワ問題
ユーザー TatsuDXTatsuDX
提出日時 2016-09-03 14:56:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 428 bytes
コンパイル時間 3,034 ms
コンパイル使用メモリ 77,844 KB
実行使用メモリ 54,308 KB
最終ジャッジ日時 2024-04-27 15:21:05
合計ジャッジ時間 7,143 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
52,748 KB
testcase_01 AC 108 ms
52,824 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 100 ms
52,656 KB
testcase_06 AC 99 ms
52,880 KB
testcase_07 AC 96 ms
52,456 KB
testcase_08 AC 106 ms
53,856 KB
testcase_09 AC 112 ms
53,880 KB
testcase_10 AC 107 ms
53,608 KB
testcase_11 AC 98 ms
52,892 KB
testcase_12 WA -
testcase_13 AC 116 ms
53,872 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 93 ms
52,788 KB
testcase_20 AC 111 ms
53,904 KB
testcase_21 WA -
testcase_22 AC 96 ms
52,720 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 97 ms
52,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int a, b, c, min = 1000;
		a = s.indexOf('c');
		while(a >= 0){
			b = s.indexOf('w', a);
			c = s.indexOf('w', b+1);
			min = Math.min(min, c-a+1);
			a = s.indexOf('c', a+1);
		}
		if(min < 1000){
			System.out.println(min);
		} else {
			System.out.println(-1);
		}
	}
}
0