結果

問題 No.436 ccw
ユーザー yagi2yagi2
提出日時 2017-04-15 19:22:13
言語 Java19
(openjdk 21)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 1,949 ms
コンパイル使用メモリ 72,000 KB
実行使用メモリ 57,040 KB
最終ジャッジ日時 2023-09-25 22:21:42
合計ジャッジ時間 6,878 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,628 KB
testcase_01 AC 116 ms
56,244 KB
testcase_02 AC 117 ms
55,792 KB
testcase_03 AC 117 ms
55,644 KB
testcase_04 AC 121 ms
55,688 KB
testcase_05 AC 117 ms
55,756 KB
testcase_06 AC 121 ms
55,760 KB
testcase_07 AC 117 ms
56,372 KB
testcase_08 AC 116 ms
55,640 KB
testcase_09 AC 117 ms
55,576 KB
testcase_10 AC 117 ms
55,880 KB
testcase_11 AC 117 ms
55,772 KB
testcase_12 AC 116 ms
55,560 KB
testcase_13 AC 117 ms
55,808 KB
testcase_14 AC 117 ms
55,856 KB
testcase_15 AC 116 ms
55,688 KB
testcase_16 AC 129 ms
55,864 KB
testcase_17 AC 123 ms
55,880 KB
testcase_18 AC 129 ms
56,012 KB
testcase_19 AC 127 ms
55,708 KB
testcase_20 AC 127 ms
55,452 KB
testcase_21 AC 187 ms
56,612 KB
testcase_22 AC 195 ms
56,528 KB
testcase_23 AC 189 ms
56,164 KB
testcase_24 AC 184 ms
56,756 KB
testcase_25 AC 187 ms
57,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        int c = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == 'w')break;
            if (S.charAt(i) == 'c') {
                c++;
            }
        }
        int w = S.length() - c;

        if (c <= w) {
            System.out.println(c-1);
        } else if (c > w) {
            System.out.println(w);
        }
    }
}
0