結果

問題 No.346 チワワ数え上げ問題
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-09-11 23:06:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 419 bytes
コンパイル時間 4,295 ms
コンパイル使用メモリ 71,004 KB
実行使用メモリ 58,092 KB
最終ジャッジ日時 2023-09-06 15:10:11
合計ジャッジ時間 7,730 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,188 KB
testcase_01 AC 118 ms
55,412 KB
testcase_02 AC 116 ms
53,356 KB
testcase_03 AC 118 ms
56,404 KB
testcase_04 AC 120 ms
56,156 KB
testcase_05 AC 117 ms
55,876 KB
testcase_06 AC 120 ms
56,040 KB
testcase_07 AC 119 ms
55,720 KB
testcase_08 AC 118 ms
55,596 KB
testcase_09 AC 119 ms
58,092 KB
testcase_10 WA -
testcase_11 AC 174 ms
56,420 KB
testcase_12 WA -
testcase_13 AC 171 ms
56,312 KB
testcase_14 AC 133 ms
55,772 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 219 ms
56,684 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 119 ms
55,940 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

        int l = s.length();
        int ans = 0;
        int wc = 0, cc = 0;

        for(int i=l-1; i>0; i--) {
            if(s.charAt(i) == 'w') wc++;
            if(s.charAt(i) == 'c') ans += wc * (wc-1) / 2;
        }

        System.out.println(ans);
    }
}
0