結果

問題 No.345 最小チワワ問題
ユーザー jimanojimano
提出日時 2018-01-21 15:31:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 2,968 ms
コンパイル使用メモリ 71,888 KB
実行使用メモリ 49,748 KB
最終ジャッジ日時 2023-08-26 19:37:15
合計ジャッジ時間 5,033 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
49,304 KB
testcase_01 AC 39 ms
47,692 KB
testcase_02 AC 39 ms
49,304 KB
testcase_03 AC 39 ms
47,408 KB
testcase_04 AC 40 ms
49,176 KB
testcase_05 AC 40 ms
49,216 KB
testcase_06 AC 39 ms
49,100 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 40 ms
49,224 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 39 ms
47,468 KB
testcase_15 AC 38 ms
49,380 KB
testcase_16 AC 38 ms
49,180 KB
testcase_17 AC 38 ms
49,292 KB
testcase_18 AC 39 ms
49,068 KB
testcase_19 AC 39 ms
49,104 KB
testcase_20 AC 39 ms
49,108 KB
testcase_21 WA -
testcase_22 AC 40 ms
49,340 KB
testcase_23 AC 39 ms
49,248 KB
testcase_24 AC 39 ms
49,216 KB
testcase_25 AC 38 ms
49,164 KB
testcase_26 AC 40 ms
49,372 KB
testcase_27 AC 40 ms
49,388 KB
testcase_28 WA -
testcase_29 AC 39 ms
49,208 KB
testcase_30 AC 38 ms
49,220 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class No0345 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			char[] array = br.readLine().toCharArray();
			int ans = Integer.MAX_VALUE;

			for (int i = 0; i < array.length; i++) {
				if (array[i] == 'c') {
					// wwを探す
					int count = 0;
					for (int j = i; j < array.length; j++) {
						if (array[j] == 'w') {
							count++;
						}
						if (count == 2)
							ans = Math.min(ans, j - i + 1);
					}
				}
			}
			System.out.println(ans);

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
0