結果

問題 No.2276 I Want AC
ユーザー aaaaaaaaaa2230
提出日時 2023-04-21 22:04:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 75,792 KB
最終ジャッジ日時 2024-11-06 15:33:59
合計ジャッジ時間 5,151 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
numA = 0
base = 0
for s in S:
    if s == "A":
        numA += 1
    else:
        base += numA

ans = base
numC = n-numA
numA = 0
for s in S:
    if s == "A":
        numA += 1
    elif s == "C":
        numC -= 1
    else:

        base -= numA
        numA += 1
        numC -= 1
        base += numC

        ans = max(ans,base)
print(ans)
0