結果

問題 No.345 最小チワワ問題
ユーザー YOSHIYOSHI
提出日時 2021-03-12 21:47:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 3,498 ms
コンパイル使用メモリ 74,756 KB
実行使用メモリ 50,488 KB
最終ジャッジ日時 2024-04-22 12:39:02
合計ジャッジ時間 6,540 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
50,116 KB
testcase_01 AC 55 ms
50,252 KB
testcase_02 AC 54 ms
50,268 KB
testcase_03 AC 54 ms
50,180 KB
testcase_04 AC 57 ms
49,932 KB
testcase_05 AC 54 ms
50,384 KB
testcase_06 AC 54 ms
50,020 KB
testcase_07 AC 54 ms
50,380 KB
testcase_08 AC 55 ms
49,984 KB
testcase_09 AC 55 ms
50,140 KB
testcase_10 AC 54 ms
50,276 KB
testcase_11 AC 55 ms
49,908 KB
testcase_12 AC 56 ms
50,024 KB
testcase_13 AC 55 ms
49,964 KB
testcase_14 AC 55 ms
50,016 KB
testcase_15 AC 54 ms
50,260 KB
testcase_16 AC 55 ms
50,268 KB
testcase_17 AC 54 ms
49,884 KB
testcase_18 AC 56 ms
50,316 KB
testcase_19 AC 56 ms
50,332 KB
testcase_20 AC 54 ms
49,912 KB
testcase_21 AC 56 ms
50,220 KB
testcase_22 AC 54 ms
49,912 KB
testcase_23 AC 54 ms
50,128 KB
testcase_24 AC 55 ms
50,000 KB
testcase_25 AC 54 ms
50,248 KB
testcase_26 AC 56 ms
50,032 KB
testcase_27 AC 54 ms
49,980 KB
testcase_28 AC 57 ms
50,276 KB
testcase_29 AC 54 ms
49,980 KB
testcase_30 AC 56 ms
50,488 KB
testcase_31 AC 54 ms
50,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No00000345_Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args) throws IOException {
		String s = br.readLine();
		int minLen = 101;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'c') {
				int wCnt = 0;
				for(int j = i; j < s.length(); j++) {
					char cSub = s.charAt(j);
					if(cSub == 'w') wCnt++;
					if(wCnt == 2 &&  j - i + 1 < minLen) {
						minLen = j - i + 1;
						break;
					}
				}
			}
		}
		System.out.println(	minLen == 101 ? -1 : minLen);
	}
}
0