結果

問題 No.346 チワワ数え上げ問題
ユーザー HachimoriHachimori
提出日時 2016-03-05 15:18:54
言語 Python2
(2.7.18)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 7,044 KB
実行使用メモリ 9,624 KB
最終ジャッジ日時 2023-10-24 19:54:27
合計ジャッジ時間 1,926 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,388 KB
testcase_01 AC 11 ms
6,388 KB
testcase_02 AC 10 ms
6,388 KB
testcase_03 AC 10 ms
6,388 KB
testcase_04 AC 10 ms
6,388 KB
testcase_05 AC 10 ms
6,388 KB
testcase_06 AC 10 ms
6,388 KB
testcase_07 AC 10 ms
6,388 KB
testcase_08 AC 9 ms
6,388 KB
testcase_09 AC 10 ms
6,388 KB
testcase_10 AC 25 ms
9,360 KB
testcase_11 AC 19 ms
8,060 KB
testcase_12 AC 22 ms
8,852 KB
testcase_13 AC 18 ms
7,796 KB
testcase_14 AC 10 ms
6,480 KB
testcase_15 AC 21 ms
8,588 KB
testcase_16 AC 22 ms
8,836 KB
testcase_17 AC 25 ms
9,360 KB
testcase_18 AC 24 ms
9,360 KB
testcase_19 AC 22 ms
9,104 KB
testcase_20 AC 25 ms
9,624 KB
testcase_21 AC 27 ms
9,624 KB
testcase_22 AC 27 ms
9,624 KB
testcase_23 AC 10 ms
6,388 KB
testcase_24 AC 10 ms
6,388 KB
testcase_25 AC 10 ms
6,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8

def read():
    return raw_input()


def work(s):
    wCnt = s.count('w')
    ans = 0
    
    for i in range(len(s)):
        if s[i] == 'c':
            ans += wCnt * (wCnt - 1) / 2
        elif s[i] == 'w':
            wCnt -= 1

    print ans


if __name__ == "__main__":
    work(read())
0