結果
問題 | No.2276 I Want AC |
ユーザー |
![]() |
提出日時 | 2023-04-21 22:02:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 412 bytes |
コンパイル時間 | 255 ms |
コンパイル使用メモリ | 82,032 KB |
実行使用メモリ | 128,040 KB |
最終ジャッジ日時 | 2024-11-06 15:32:58 |
合計ジャッジ時間 | 6,824 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 56 |
ソースコード
N=int(input())S=input()A,C,B=[],[],[];a,c,b=0,0,0D=[]for i in range(N):if S[i]=='A':a+=1elif S[i]=='C':c+=1else:b+=1D.append(i)A.append(a);C.append(c);B.append(b)ans=0for i in range(N):if S[i]!='A':ans+=A[i]now=ans;ss=S.count('?')bl,br=0,ss-1for i in range(ss):d=D[i]al,cr=A[d],C[-1]-C[d]now+=br+cr-al-blans=max(ans,now)bl+=1;br-=1print(ans)