結果

問題 No.345 最小チワワ問題
ユーザー TatsuDXTatsuDX
提出日時 2016-09-03 15:00:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 7,249 ms
コンパイル使用メモリ 77,996 KB
実行使用メモリ 57,752 KB
最終ジャッジ日時 2023-10-26 04:01:36
合計ジャッジ時間 10,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
57,716 KB
testcase_01 AC 130 ms
57,444 KB
testcase_02 AC 133 ms
57,220 KB
testcase_03 AC 132 ms
57,464 KB
testcase_04 AC 135 ms
57,536 KB
testcase_05 AC 128 ms
57,492 KB
testcase_06 AC 130 ms
57,212 KB
testcase_07 AC 135 ms
57,516 KB
testcase_08 AC 137 ms
57,476 KB
testcase_09 AC 131 ms
57,188 KB
testcase_10 AC 134 ms
57,560 KB
testcase_11 AC 131 ms
57,260 KB
testcase_12 AC 134 ms
57,536 KB
testcase_13 AC 136 ms
57,304 KB
testcase_14 AC 132 ms
57,228 KB
testcase_15 AC 133 ms
57,752 KB
testcase_16 AC 137 ms
57,224 KB
testcase_17 AC 134 ms
57,476 KB
testcase_18 AC 132 ms
57,228 KB
testcase_19 AC 138 ms
57,288 KB
testcase_20 AC 131 ms
57,628 KB
testcase_21 AC 132 ms
57,216 KB
testcase_22 AC 131 ms
57,424 KB
testcase_23 AC 131 ms
57,244 KB
testcase_24 AC 130 ms
57,468 KB
testcase_25 AC 130 ms
57,504 KB
testcase_26 AC 125 ms
57,096 KB
testcase_27 AC 128 ms
57,496 KB
testcase_28 AC 128 ms
57,376 KB
testcase_29 AC 129 ms
57,468 KB
testcase_30 AC 132 ms
57,492 KB
testcase_31 AC 129 ms
57,444 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);
			if(b > 0){
				c = s.indexOf('w', b+1);
				if(c > 0){
					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