結果

問題 No.345 最小チワワ問題
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-16 21:36:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 74,020 KB
実行使用メモリ 41,708 KB
最終ジャッジ日時 2024-04-28 23:53:39
合計ジャッジ時間 7,460 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,436 KB
testcase_01 AC 126 ms
41,116 KB
testcase_02 AC 125 ms
41,236 KB
testcase_03 AC 125 ms
41,040 KB
testcase_04 WA -
testcase_05 AC 127 ms
41,128 KB
testcase_06 WA -
testcase_07 AC 128 ms
41,356 KB
testcase_08 AC 128 ms
41,356 KB
testcase_09 AC 128 ms
41,312 KB
testcase_10 AC 113 ms
40,188 KB
testcase_11 AC 129 ms
41,160 KB
testcase_12 AC 141 ms
41,080 KB
testcase_13 AC 144 ms
41,316 KB
testcase_14 AC 134 ms
41,320 KB
testcase_15 WA -
testcase_16 AC 126 ms
41,256 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 125 ms
41,032 KB
testcase_21 AC 125 ms
41,176 KB
testcase_22 AC 126 ms
41,148 KB
testcase_23 AC 127 ms
40,816 KB
testcase_24 AC 127 ms
41,108 KB
testcase_25 AC 126 ms
41,096 KB
testcase_26 AC 127 ms
41,088 KB
testcase_27 WA -
testcase_28 AC 124 ms
41,060 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 126 ms
41,188 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 n = s.length();
		int ans = 1001001001;
		for(int i = 0 ; i < n ; i++) {
			for(int j = i + 1 ; j < n ; j++) {
				for(int k = j + 1 ; k < n ; k++) {
					if(s.charAt(i) == 'c' && s.charAt(j) == 'w' && s.charAt(k) == 'w') {
						ans = k - i + 1;
					}
				}
			}
		}
		if(ans == 1001001001) {
			System.out.println(-1);
		} else {
			System.out.println(ans);
		}
 	}
}
0