結果

問題 No.436 ccw
ユーザー GoryudyumaGoryudyuma
提出日時 2017-02-15 23:53:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 1,858 ms
コンパイル使用メモリ 72,296 KB
実行使用メモリ 58,028 KB
最終ジャッジ日時 2023-08-28 17:36:51
合計ジャッジ時間 6,584 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,772 KB
testcase_01 AC 115 ms
55,620 KB
testcase_02 AC 115 ms
55,344 KB
testcase_03 AC 121 ms
55,856 KB
testcase_04 AC 123 ms
55,532 KB
testcase_05 AC 117 ms
56,004 KB
testcase_06 AC 116 ms
55,724 KB
testcase_07 AC 116 ms
55,932 KB
testcase_08 AC 116 ms
55,604 KB
testcase_09 AC 117 ms
55,628 KB
testcase_10 AC 117 ms
55,996 KB
testcase_11 AC 118 ms
55,944 KB
testcase_12 AC 123 ms
55,644 KB
testcase_13 AC 117 ms
55,860 KB
testcase_14 AC 118 ms
58,028 KB
testcase_15 AC 117 ms
55,468 KB
testcase_16 AC 132 ms
55,644 KB
testcase_17 AC 125 ms
57,884 KB
testcase_18 AC 132 ms
55,512 KB
testcase_19 AC 133 ms
55,696 KB
testcase_20 AC 132 ms
56,056 KB
testcase_21 AC 198 ms
56,116 KB
testcase_22 AC 198 ms
56,660 KB
testcase_23 AC 196 ms
54,188 KB
testcase_24 AC 199 ms
54,520 KB
testcase_25 AC 201 ms
56,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next();
                        int c = 0, w = 0;
                        for (int i = 0; i < S.length(); i++) {
                                if (S.charAt(i) == 'c') {
                                        c++;
                                } else {
                                        w++;
                                }
                        }
                        System.out.println(Math.max(0, Math.min(c - 1, w)));
                }
        }
}
0