結果

問題 No.345 最小チワワ問題
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-13 19:28:07
言語 Java19
(openjdk 21)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 3,595 ms
コンパイル使用メモリ 79,596 KB
実行使用メモリ 57,740 KB
最終ジャッジ日時 2023-10-26 04:17:04
合計ジャッジ時間 8,116 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,468 KB
testcase_01 AC 128 ms
57,444 KB
testcase_02 AC 130 ms
57,496 KB
testcase_03 AC 124 ms
57,136 KB
testcase_04 AC 129 ms
57,648 KB
testcase_05 AC 131 ms
57,224 KB
testcase_06 AC 129 ms
57,256 KB
testcase_07 AC 132 ms
57,468 KB
testcase_08 AC 129 ms
57,452 KB
testcase_09 AC 131 ms
57,544 KB
testcase_10 AC 132 ms
57,416 KB
testcase_11 AC 131 ms
57,440 KB
testcase_12 AC 141 ms
57,180 KB
testcase_13 AC 142 ms
57,492 KB
testcase_14 AC 144 ms
57,176 KB
testcase_15 AC 136 ms
57,224 KB
testcase_16 AC 133 ms
55,476 KB
testcase_17 AC 125 ms
57,244 KB
testcase_18 AC 131 ms
57,440 KB
testcase_19 AC 126 ms
57,508 KB
testcase_20 AC 132 ms
57,432 KB
testcase_21 AC 131 ms
57,444 KB
testcase_22 AC 133 ms
57,740 KB
testcase_23 AC 129 ms
57,688 KB
testcase_24 AC 130 ms
57,488 KB
testcase_25 AC 127 ms
57,628 KB
testcase_26 AC 128 ms
57,688 KB
testcase_27 AC 130 ms
57,620 KB
testcase_28 AC 128 ms
57,504 KB
testcase_29 AC 131 ms
57,552 KB
testcase_30 AC 130 ms
57,552 KB
testcase_31 AC 127 ms
57,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 1001001001;
		for(int i = 0 ; i < s.length() ; i++) {
			for(int j = i + 1 ; j < s.length() ; j++) {
				for(int k = j + 1 ; k < s.length() ; k++) {
					if(s.charAt(i) == 'c' && s.charAt(j) == 'w' && s.charAt(k) == 'w') {
						ans = Math.min(ans, k - i + 1);
					}
				}
			}
		}
		if(ans == 1001001001) {
			System.out.println(-1);
		} else {
			System.out.println(ans);
		}
	}
}
0