結果

問題 No.345 最小チワワ問題
ユーザー marumaru
提出日時 2017-09-21 21:56:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 3,758 ms
コンパイル使用メモリ 75,016 KB
実行使用メモリ 54,588 KB
最終ジャッジ日時 2024-04-26 06:43:07
合計ジャッジ時間 8,214 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
54,140 KB
testcase_01 AC 122 ms
54,220 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 107 ms
52,864 KB
testcase_05 WA -
testcase_06 AC 121 ms
54,228 KB
testcase_07 AC 117 ms
54,192 KB
testcase_08 AC 108 ms
54,020 KB
testcase_09 AC 121 ms
54,164 KB
testcase_10 AC 121 ms
53,848 KB
testcase_11 AC 121 ms
53,816 KB
testcase_12 AC 121 ms
54,096 KB
testcase_13 WA -
testcase_14 AC 123 ms
54,320 KB
testcase_15 AC 121 ms
53,916 KB
testcase_16 AC 125 ms
54,124 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 123 ms
54,232 KB
testcase_20 AC 122 ms
53,836 KB
testcase_21 AC 128 ms
53,832 KB
testcase_22 AC 122 ms
53,976 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 114 ms
52,728 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 119 ms
54,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicode;

import java.util.Scanner;

public class chiwawa {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		String[] s_array = input.split("");

			int cwwArray[] = new int[3];
			for (int i = 0; i < s_array.length; i++) {
				if (s_array[i].equals("c") && cwwArray[2] == 0) {
					cwwArray[0] = i;
				} else if (s_array[i].equals("w") && cwwArray[1] == 0) {
					cwwArray[1] = i;
				} else if (s_array[i].equals("w") && cwwArray[2] == 0) {
					cwwArray[2] = i;
				}
			}
			if (cwwArray[2] == 0) {
				System.out.println(-1);
			} else {
				System.out.println(cwwArray[2] - cwwArray[0] + 1);
			}
			scanner.close();
	}
}
0