結果

問題 No.2276 I Want AC
ユーザー titiatitia
提出日時 2023-04-22 00:23:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 24,916 KB
最終ジャッジ日時 2024-04-24 10:01:52
合計ジャッジ時間 18,935 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
11,008 KB
testcase_01 AC 24 ms
11,008 KB
testcase_02 AC 24 ms
11,008 KB
testcase_03 AC 27 ms
10,880 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 25 ms
10,880 KB
testcase_06 AC 26 ms
10,880 KB
testcase_07 AC 26 ms
10,880 KB
testcase_08 WA -
testcase_09 AC 25 ms
11,136 KB
testcase_10 AC 24 ms
11,008 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 126 ms
14,348 KB
testcase_36 AC 118 ms
14,344 KB
testcase_37 AC 1,687 ms
24,916 KB
testcase_38 AC 256 ms
16,088 KB
testcase_39 AC 232 ms
16,220 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 1,919 ms
24,788 KB
testcase_43 AC 1,982 ms
24,912 KB
testcase_44 AC 135 ms
14,476 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 214 ms
16,280 KB
testcase_58 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)))
0