結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2023-12-28 13:22:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 271 bytes |
コンパイル時間 | 451 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 80,884 KB |
最終ジャッジ日時 | 2024-09-27 15:44:00 |
合計ジャッジ時間 | 3,021 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
from bisect import * S = input() cpos = [] wpos = [] for i, s in enumerate(S): if s == "c": cpos.append(i) if s == "w": wpos.append(i) nw = len(wpos) ans = 0 for c in cpos: x = nw - bisect_left(wpos, c) ans += x * (x - 1) // 2 print(ans)