結果

問題 No.2276 I Want AC
ユーザー 👑 timitimi
提出日時 2023-04-21 22:02:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 127,012 KB
最終ジャッジ日時 2024-04-24 08:11:23
合計ジャッジ時間 6,903 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,340 KB
testcase_01 AC 35 ms
51,840 KB
testcase_02 AC 33 ms
52,352 KB
testcase_03 AC 35 ms
52,096 KB
testcase_04 AC 34 ms
51,840 KB
testcase_05 AC 33 ms
52,480 KB
testcase_06 AC 34 ms
52,096 KB
testcase_07 AC 34 ms
52,096 KB
testcase_08 AC 38 ms
52,480 KB
testcase_09 AC 38 ms
52,284 KB
testcase_10 AC 35 ms
52,352 KB
testcase_11 AC 68 ms
79,232 KB
testcase_12 AC 96 ms
108,544 KB
testcase_13 AC 67 ms
77,824 KB
testcase_14 AC 66 ms
70,912 KB
testcase_15 AC 74 ms
88,832 KB
testcase_16 AC 73 ms
86,956 KB
testcase_17 AC 93 ms
109,696 KB
testcase_18 AC 82 ms
96,000 KB
testcase_19 AC 54 ms
65,408 KB
testcase_20 AC 103 ms
118,232 KB
testcase_21 AC 68 ms
82,944 KB
testcase_22 AC 59 ms
72,832 KB
testcase_23 AC 97 ms
114,432 KB
testcase_24 AC 97 ms
114,048 KB
testcase_25 AC 98 ms
114,560 KB
testcase_26 AC 101 ms
116,864 KB
testcase_27 AC 94 ms
115,840 KB
testcase_28 AC 95 ms
112,512 KB
testcase_29 AC 89 ms
110,592 KB
testcase_30 AC 102 ms
115,200 KB
testcase_31 AC 92 ms
108,416 KB
testcase_32 AC 97 ms
116,848 KB
testcase_33 AC 95 ms
115,132 KB
testcase_34 AC 97 ms
118,528 KB
testcase_35 AC 76 ms
103,808 KB
testcase_36 AC 77 ms
104,320 KB
testcase_37 AC 95 ms
121,088 KB
testcase_38 AC 83 ms
106,240 KB
testcase_39 AC 83 ms
106,240 KB
testcase_40 AC 90 ms
106,752 KB
testcase_41 AC 84 ms
106,624 KB
testcase_42 AC 105 ms
123,904 KB
testcase_43 AC 112 ms
127,012 KB
testcase_44 AC 84 ms
105,984 KB
testcase_45 AC 93 ms
114,816 KB
testcase_46 AC 95 ms
114,816 KB
testcase_47 AC 88 ms
107,648 KB
testcase_48 AC 89 ms
108,032 KB
testcase_49 AC 106 ms
118,528 KB
testcase_50 AC 103 ms
118,656 KB
testcase_51 AC 108 ms
119,384 KB
testcase_52 AC 103 ms
118,144 KB
testcase_53 AC 100 ms
116,352 KB
testcase_54 AC 98 ms
112,512 KB
testcase_55 AC 104 ms
112,000 KB
testcase_56 AC 91 ms
109,876 KB
testcase_57 AC 93 ms
108,544 KB
testcase_58 AC 93 ms
109,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
A,C,B=[],[],[];a,c,b=0,0,0
D=[]
for i in range(N):
  if S[i]=='A':
    a+=1
  elif S[i]=='C':
    c+=1 
  else:
    b+=1
    D.append(i)
  A.append(a);C.append(c);B.append(b)

ans=0
for i in range(N):
  if S[i]!='A':
    ans+=A[i]

now=ans;ss=S.count('?')
bl,br=0,ss-1
for i in range(ss):
  d=D[i]
  al,cr=A[d],C[-1]-C[d]
  now+=br+cr-al-bl
  ans=max(ans,now)
  bl+=1;br-=1
print(ans)
  
0