結果
| 問題 | No.2276 I Want AC | 
| コンテスト | |
| ユーザー |  rlangevin | 
| 提出日時 | 2023-04-21 21:33:07 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 378 bytes | 
| コンパイル時間 | 313 ms | 
| コンパイル使用メモリ | 82,216 KB | 
| 実行使用メモリ | 75,736 KB | 
| 最終ジャッジ日時 | 2024-11-06 15:00:41 | 
| 合計ジャッジ時間 | 5,540 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 16 WA * 40 | 
ソースコード
N = int(input())
S = list(input())
ans = 0
cnt = 0
for i in range(N):
    if S[i] == "A" or S[i] == "?":
        cnt += 1
    else:
        ans += cnt
        
num = ans
cntC = 0
for i in range(N - 1, -1, -1):
    if S[i] == "?":
        cnt -= 1
        num += cnt
        num -= cntC
        cntC += 1
    elif S[i] == "C":
        cntC += 1
    ans = max(ans, num)
print(ans)
            
            
            
        