結果
| 問題 |
No.2276 I Want AC
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2023-04-22 00:23:59 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,136 bytes |
| コンパイル時間 | 333 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 24,788 KB |
| 最終ジャッジ日時 | 2024-11-06 17:32:51 |
| 合計ジャッジ時間 | 21,763 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 40 TLE * 2 |
ソースコード
import sys
input = sys.stdin.readline
N=int(input())
S=input().strip()
LIST=[]
for i in range(N):
if S[i]=="?":
LIST.append(i)
def score(A):
ANS=0
now=0
for x in A:
if x=="A":
now+=1
else:
ANS+=now
return ANS
MIN=0
MAX=len(LIST)
while MAX>MIN+1:
l=(MIN+MAX)//2
A=[]
B=[]
for i in range(len(S)):
s=S[i]
if s!="?":
A.append(s)
B.append(s)
else:
if i<=l:
A.append("A")
else:
A.append("C")
if i<=l+1:
B.append("A")
else:
B.append("C")
if score(A)<score(B):
MIN=l+1
elif score(A)>score(B):
MAX=l
else:
MIN=l
MAX=l+1
l=MIN
A=[]
B=[]
for i in range(len(S)):
s=S[i]
if s!="?":
A.append(s)
B.append(s)
else:
if i<=l:
A.append("A")
else:
A.append("C")
if i<=l+1:
B.append("A")
else:
B.append("C")
print(max(score(A),score(B)))
titia