結果

問題 No.346 チワワ数え上げ問題
ユーザー ronpooronpoo
提出日時 2023-08-23 20:32:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 236 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 77,108 KB
最終ジャッジ日時 2023-08-23 20:33:01
合計ジャッジ時間 3,560 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,408 KB
testcase_01 AC 71 ms
71,568 KB
testcase_02 AC 72 ms
71,112 KB
testcase_03 AC 70 ms
71,460 KB
testcase_04 AC 74 ms
71,568 KB
testcase_05 AC 71 ms
71,304 KB
testcase_06 AC 71 ms
71,272 KB
testcase_07 AC 69 ms
71,408 KB
testcase_08 AC 71 ms
71,272 KB
testcase_09 AC 76 ms
71,656 KB
testcase_10 AC 77 ms
76,972 KB
testcase_11 AC 77 ms
76,520 KB
testcase_12 AC 78 ms
76,616 KB
testcase_13 AC 77 ms
76,272 KB
testcase_14 AC 75 ms
75,992 KB
testcase_15 AC 79 ms
76,716 KB
testcase_16 AC 78 ms
76,684 KB
testcase_17 AC 78 ms
77,104 KB
testcase_18 AC 78 ms
76,804 KB
testcase_19 AC 78 ms
76,672 KB
testcase_20 AC 77 ms
76,872 KB
testcase_21 AC 77 ms
76,948 KB
testcase_22 AC 83 ms
77,108 KB
testcase_23 AC 70 ms
71,284 KB
testcase_24 AC 71 ms
71,428 KB
testcase_25 AC 70 ms
71,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
L = len(S)

wcnt = [0] * L
ans = 0
for i in range(L-1, -1, -1):
    if i != L-1:
        wcnt[i] = wcnt[i+1]
    if S[i] == 'w':
        wcnt[i] += 1
    elif S[i] == 'c':
        ans += wcnt[i] * (wcnt[i]-1) // 2
print(ans)
0