結果

問題 No.345 最小チワワ問題
ユーザー 4A9GN4A9GN
提出日時 2016-07-21 21:17:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 1,770 ms
コンパイル使用メモリ 74,984 KB
実行使用メモリ 41,284 KB
最終ジャッジ日時 2024-04-24 01:04:16
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
41,168 KB
testcase_01 AC 97 ms
40,160 KB
testcase_02 AC 96 ms
39,996 KB
testcase_03 AC 110 ms
41,196 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 92 ms
40,280 KB
testcase_08 AC 104 ms
40,884 KB
testcase_09 AC 101 ms
41,112 KB
testcase_10 AC 104 ms
40,952 KB
testcase_11 AC 95 ms
40,268 KB
testcase_12 AC 90 ms
39,764 KB
testcase_13 AC 89 ms
39,544 KB
testcase_14 WA -
testcase_15 AC 102 ms
41,284 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 109 ms
41,148 KB
testcase_20 AC 98 ms
39,484 KB
testcase_21 AC 105 ms
41,148 KB
testcase_22 AC 103 ms
41,116 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 101 ms
40,108 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 105 ms
41,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Character> ch = new ArrayList<Character>();
        String str = sc.next();
        for (char c : str.toCharArray())
            ch.add(c);
        int n = -1;
        int cnt = 0;
        int size = 0;
        
        for (int i = 0; i < ch.size(); i++) {
            if (cnt == 3) break;
            switch (cnt) {
                case 0:
                    if (ch.get(i) == 'c') { cnt++; size++; };
                    break;
                case 1:
                case 2:
                    if (ch.get(i) == 'w') cnt++;
                    size++;
                    break;
            }
        }
        if (cnt == 3) System.out.printf("%d\n", size);
        else System.out.println("-1");
    }
}
0