結果

問題 No.345 最小チワワ問題
ユーザー TatsuDXTatsuDX
提出日時 2016-09-03 14:58:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 3,625 ms
コンパイル使用メモリ 75,376 KB
実行使用メモリ 55,920 KB
最終ジャッジ日時 2024-04-27 15:21:19
合計ジャッジ時間 7,443 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
53,736 KB
testcase_01 AC 105 ms
53,100 KB
testcase_02 AC 115 ms
53,888 KB
testcase_03 AC 101 ms
52,760 KB
testcase_04 AC 114 ms
53,864 KB
testcase_05 AC 97 ms
52,584 KB
testcase_06 AC 96 ms
52,520 KB
testcase_07 AC 112 ms
54,096 KB
testcase_08 AC 112 ms
54,208 KB
testcase_09 AC 113 ms
53,880 KB
testcase_10 AC 113 ms
53,972 KB
testcase_11 AC 128 ms
53,804 KB
testcase_12 AC 118 ms
53,696 KB
testcase_13 AC 114 ms
53,808 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 120 ms
54,184 KB
testcase_18 AC 103 ms
52,580 KB
testcase_19 AC 110 ms
53,880 KB
testcase_20 AC 118 ms
53,756 KB
testcase_21 AC 115 ms
53,740 KB
testcase_22 AC 113 ms
54,136 KB
testcase_23 WA -
testcase_24 AC 114 ms
54,048 KB
testcase_25 AC 118 ms
53,944 KB
testcase_26 AC 118 ms
53,920 KB
testcase_27 AC 102 ms
52,572 KB
testcase_28 AC 117 ms
53,928 KB
testcase_29 AC 113 ms
54,176 KB
testcase_30 WA -
testcase_31 AC 112 ms
54,028 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);
			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