結果

問題 No.345 最小チワワ問題
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-16 21:36:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 2,932 ms
コンパイル使用メモリ 71,876 KB
実行使用メモリ 56,548 KB
最終ジャッジ日時 2023-08-11 07:16:05
合計ジャッジ時間 7,671 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
56,204 KB
testcase_01 AC 111 ms
55,892 KB
testcase_02 AC 112 ms
56,356 KB
testcase_03 AC 111 ms
56,052 KB
testcase_04 WA -
testcase_05 AC 114 ms
56,064 KB
testcase_06 WA -
testcase_07 AC 112 ms
55,892 KB
testcase_08 AC 113 ms
56,088 KB
testcase_09 AC 114 ms
55,708 KB
testcase_10 AC 113 ms
55,596 KB
testcase_11 AC 116 ms
55,924 KB
testcase_12 AC 125 ms
55,552 KB
testcase_13 AC 125 ms
56,024 KB
testcase_14 AC 124 ms
56,012 KB
testcase_15 WA -
testcase_16 AC 113 ms
56,068 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 113 ms
55,712 KB
testcase_21 AC 112 ms
56,044 KB
testcase_22 AC 113 ms
56,036 KB
testcase_23 AC 113 ms
56,332 KB
testcase_24 AC 114 ms
55,420 KB
testcase_25 AC 113 ms
55,628 KB
testcase_26 AC 113 ms
56,180 KB
testcase_27 WA -
testcase_28 AC 114 ms
56,056 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 112 ms
55,980 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