結果

問題 No.345 最小チワワ問題
ユーザー きつねうどんきつねうどん
提出日時 2023-11-24 22:53:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,552 bytes
コンパイル時間 2,487 ms
コンパイル使用メモリ 77,692 KB
実行使用メモリ 58,096 KB
最終ジャッジ日時 2023-11-24 22:53:49
合計ジャッジ時間 7,658 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
56,688 KB
testcase_01 AC 120 ms
57,832 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 119 ms
57,828 KB
testcase_05 AC 110 ms
56,688 KB
testcase_06 AC 118 ms
57,960 KB
testcase_07 AC 128 ms
56,692 KB
testcase_08 AC 122 ms
57,840 KB
testcase_09 AC 112 ms
56,696 KB
testcase_10 AC 119 ms
57,960 KB
testcase_11 AC 128 ms
57,832 KB
testcase_12 AC 133 ms
57,696 KB
testcase_13 AC 132 ms
57,968 KB
testcase_14 AC 126 ms
57,800 KB
testcase_15 AC 147 ms
58,080 KB
testcase_16 AC 123 ms
57,960 KB
testcase_17 WA -
testcase_18 AC 123 ms
57,840 KB
testcase_19 AC 122 ms
57,884 KB
testcase_20 AC 123 ms
57,824 KB
testcase_21 AC 122 ms
56,688 KB
testcase_22 AC 126 ms
57,716 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 123 ms
58,084 KB
testcase_29 AC 122 ms
57,728 KB
testcase_30 AC 123 ms
57,952 KB
testcase_31 AC 121 ms
57,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main {
    public static class Pair {
        public Integer status;
        public Integer length;

        public Pair(Integer s, Integer l) {
            this.status = s;
            this.length = l;
        }


    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.next();
        String[] strArray = a.split("");
        List<Pair> pairList = new ArrayList<Pair>();
        for (String s : strArray) {
            if (s.equals("c")) {
                Pair pair = new Pair(0, 1);
                pairList.add(pair);
            } else if (s.equals("w")) {
                for (Pair p : pairList) {
                    if (p.status == 2) {
                        continue;
                    }
                    p.status++;
                    p.length++;
                }
            } else {
                for (Pair p : pairList) {
                    if (p.status == 2) {
                        continue;
                    }
                    p.length++;
                }
            }
        }

        int minLength = 101;
        for (Pair p : pairList) {
            if (p.status == 2) {
                if (p.length < minLength) {
                    minLength = p.length;
                }
            }
        }
        if (minLength == 101) {
            System.out.println(-1);
        } else {
            System.out.println(minLength);
        }
    }
}
0