結果

問題 No.345 最小チワワ問題
ユーザー jimanojimano
提出日時 2018-01-21 16:32:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 734 bytes
コンパイル時間 4,892 ms
コンパイル使用メモリ 71,744 KB
実行使用メモリ 51,420 KB
最終ジャッジ日時 2023-08-26 19:42:09
合計ジャッジ時間 7,299 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,336 KB
testcase_01 AC 40 ms
49,136 KB
testcase_02 AC 43 ms
49,576 KB
testcase_03 AC 42 ms
49,084 KB
testcase_04 AC 41 ms
49,136 KB
testcase_05 AC 42 ms
49,408 KB
testcase_06 AC 42 ms
49,052 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 41 ms
49,288 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 43 ms
49,496 KB
testcase_15 AC 41 ms
49,316 KB
testcase_16 AC 43 ms
49,568 KB
testcase_17 AC 43 ms
49,048 KB
testcase_18 AC 43 ms
49,228 KB
testcase_19 AC 45 ms
49,420 KB
testcase_20 AC 46 ms
49,692 KB
testcase_21 WA -
testcase_22 AC 41 ms
49,284 KB
testcase_23 AC 41 ms
49,336 KB
testcase_24 AC 41 ms
49,232 KB
testcase_25 AC 41 ms
49,224 KB
testcase_26 AC 42 ms
49,228 KB
testcase_27 AC 44 ms
49,324 KB
testcase_28 WA -
testcase_29 AC 42 ms
49,304 KB
testcase_30 AC 42 ms
49,320 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;

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

public class No0345_2 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String str = br.readLine();
			int ans = Integer.MAX_VALUE;
			int idx = str.indexOf("c");

			while (idx != -1) {
				str = str.substring(idx + 1);
				int idxW1 = str.indexOf("w");
				int idxW2 = str.substring(idxW1 + 1).indexOf("w");
				int tmp = (idxW1 != -1 && idxW2 != -1) ? idxW1 + idxW2 + 3 : ans;
				ans = Math.min(ans, tmp);

				idx = str.indexOf("c");
			}
			System.out.println(ans);

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