結果

問題 No.436 ccw
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-05-03 21:43:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 2,244 ms
コンパイル使用メモリ 71,992 KB
実行使用メモリ 35,032 KB
最終ジャッジ日時 2023-10-12 08:03:18
合計ジャッジ時間 5,074 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
33,276 KB
testcase_01 AC 40 ms
33,360 KB
testcase_02 AC 40 ms
33,488 KB
testcase_03 AC 41 ms
33,588 KB
testcase_04 AC 40 ms
33,244 KB
testcase_05 AC 39 ms
33,260 KB
testcase_06 AC 40 ms
33,312 KB
testcase_07 AC 42 ms
33,332 KB
testcase_08 AC 39 ms
33,324 KB
testcase_09 AC 41 ms
33,660 KB
testcase_10 AC 40 ms
33,332 KB
testcase_11 AC 41 ms
33,328 KB
testcase_12 AC 40 ms
33,492 KB
testcase_13 AC 40 ms
33,160 KB
testcase_14 AC 41 ms
33,336 KB
testcase_15 AC 43 ms
33,600 KB
testcase_16 AC 42 ms
33,196 KB
testcase_17 AC 42 ms
33,356 KB
testcase_18 AC 43 ms
33,248 KB
testcase_19 AC 43 ms
33,312 KB
testcase_20 AC 42 ms
33,628 KB
testcase_21 AC 65 ms
34,788 KB
testcase_22 AC 63 ms
34,560 KB
testcase_23 AC 63 ms
34,680 KB
testcase_24 AC 68 ms
35,032 KB
testcase_25 AC 63 ms
34,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String S = reader.readLine();
        int Ccounter = 0;
        int Wcounter = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == 'c') {
                Ccounter += 1;
            } else {
                Wcounter += 1;
            }
        }
        if (Ccounter > Wcounter) {
            System.out.println(Wcounter);
        } else if (Ccounter < Wcounter) {
            System.out.println(Ccounter-1);
        } else {
            System.out.println(Ccounter-1);
        }
    }
}
0