結果

問題 No.345 最小チワワ問題
ユーザー jimanojimano
提出日時 2018-01-21 15:34:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 758 bytes
コンパイル時間 5,228 ms
コンパイル使用メモリ 74,480 KB
実行使用メモリ 53,236 KB
最終ジャッジ日時 2023-10-26 04:23:40
合計ジャッジ時間 7,225 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
52,356 KB
testcase_01 AC 57 ms
52,200 KB
testcase_02 AC 59 ms
52,388 KB
testcase_03 AC 60 ms
52,356 KB
testcase_04 AC 59 ms
52,376 KB
testcase_05 AC 61 ms
53,232 KB
testcase_06 AC 57 ms
52,204 KB
testcase_07 AC 59 ms
53,220 KB
testcase_08 AC 57 ms
52,364 KB
testcase_09 AC 62 ms
53,220 KB
testcase_10 AC 57 ms
52,216 KB
testcase_11 AC 60 ms
52,216 KB
testcase_12 AC 58 ms
53,236 KB
testcase_13 AC 57 ms
53,224 KB
testcase_14 AC 60 ms
52,392 KB
testcase_15 AC 58 ms
52,220 KB
testcase_16 AC 56 ms
53,220 KB
testcase_17 AC 57 ms
53,220 KB
testcase_18 AC 57 ms
52,212 KB
testcase_19 AC 56 ms
53,228 KB
testcase_20 AC 57 ms
51,312 KB
testcase_21 AC 56 ms
53,228 KB
testcase_22 AC 56 ms
53,220 KB
testcase_23 AC 57 ms
52,364 KB
testcase_24 AC 57 ms
52,352 KB
testcase_25 AC 55 ms
52,364 KB
testcase_26 AC 54 ms
53,220 KB
testcase_27 AC 56 ms
52,340 KB
testcase_28 AC 56 ms
53,224 KB
testcase_29 AC 55 ms
53,216 KB
testcase_30 AC 55 ms
52,364 KB
testcase_31 AC 56 ms
52,372 KB
権限があれば一括ダウンロードができます

ソースコード

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 != Integer.MAX_VALUE ? ans : -1);

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