結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,880 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 26 ms
11,008 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 25 ms
10,880 KB
testcase_06 WA -
testcase_07 AC 26 ms
10,880 KB
testcase_08 AC 27 ms
10,880 KB
testcase_09 AC 29 ms
10,880 KB
testcase_10 AC 26 ms
10,880 KB
testcase_11 AC 270 ms
13,056 KB
testcase_12 AC 808 ms
17,496 KB
testcase_13 AC 308 ms
12,932 KB
testcase_14 AC 180 ms
12,032 KB
testcase_15 AC 561 ms
14,720 KB
testcase_16 AC 444 ms
14,336 KB
testcase_17 AC 1,182 ms
18,528 KB
testcase_18 AC 707 ms
16,132 KB
testcase_19 AC 52 ms
11,264 KB
testcase_20 AC 1,303 ms
20,840 KB
testcase_21 AC 374 ms
13,568 KB
testcase_22 AC 173 ms
12,104 KB
testcase_23 AC 902 ms
18,664 KB
testcase_24 AC 885 ms
18,672 KB
testcase_25 AC 1,123 ms
18,664 KB
testcase_26 AC 1,291 ms
20,456 KB
testcase_27 AC 1,221 ms
19,688 KB
testcase_28 AC 948 ms
18,020 KB
testcase_29 AC 809 ms
16,996 KB
testcase_30 AC 1,160 ms
19,304 KB
testcase_31 AC 595 ms
16,100 KB
testcase_32 AC 1,215 ms
19,688 KB
testcase_33 AC 1,051 ms
19,172 KB
testcase_34 AC 1,330 ms
21,484 KB
testcase_35 AC 121 ms
14,312 KB
testcase_36 AC 97 ms
14,184 KB
testcase_37 AC 1,817 ms
23,908 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 188 ms
15,724 KB
testcase_41 AC 234 ms
15,848 KB
testcase_42 AC 1,995 ms
24,036 KB
testcase_43 AC 1,717 ms
23,784 KB
testcase_44 AC 137 ms
14,184 KB
testcase_45 AC 1,261 ms
20,068 KB
testcase_46 AC 1,207 ms
19,944 KB
testcase_47 AC 233 ms
15,848 KB
testcase_48 AC 184 ms
15,852 KB
testcase_49 AC 1,263 ms
20,072 KB
testcase_50 AC 1,211 ms
19,816 KB
testcase_51 AC 1,262 ms
19,944 KB
testcase_52 AC 1,195 ms
19,940 KB
testcase_53 AC 1,125 ms
19,944 KB
testcase_54 AC 777 ms
17,264 KB
testcase_55 AC 719 ms
16,680 KB
testcase_56 AC 557 ms
16,228 KB
testcase_57 WA -
testcase_58 AC 497 ms
16,164 KB
権限があれば一括ダウンロードができます

ソースコード

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

while MAX>MIN+1:
    l=(MIN+MAX)//2

    A=list(S)
    B=list(S)

    for i in range(len(LIST)):
        if i<=l:
            A[LIST[i]]="A"
        else:
            A[LIST[i]]="C"

        if i<=l+1:
            B[LIST[i]]="A"
        else:
            B[LIST[i]]="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=list(S)
B=list(S)

for i in range(len(LIST)):
    if i<=l:
        A[LIST[i]]="A"
    else:
        A[LIST[i]]="C"

    if i<=l+1:
        B[LIST[i]]="A"
    else:
        B[LIST[i]]="C"

if score(A)<score(B):
    MIN=l+1
elif score(A)>score(B):
    MAX=l
else:
    MIN=l
    MAX=l+1
        
print(max(score(A),score(B)))
0