結果

問題 No.2276 I Want AC
ユーザー titiatitia
提出日時 2023-04-22 00:37:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 934 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 23,896 KB
最終ジャッジ日時 2024-04-24 10:10:44
合計ジャッジ時間 43,045 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 32 ms
11,008 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 33 ms
11,008 KB
testcase_05 AC 33 ms
10,880 KB
testcase_06 AC 33 ms
10,752 KB
testcase_07 AC 31 ms
10,880 KB
testcase_08 AC 32 ms
10,880 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 299 ms
13,184 KB
testcase_12 AC 921 ms
17,628 KB
testcase_13 AC 330 ms
13,056 KB
testcase_14 AC 198 ms
12,160 KB
testcase_15 AC 604 ms
14,848 KB
testcase_16 AC 495 ms
14,284 KB
testcase_17 AC 1,168 ms
18,380 KB
testcase_18 AC 743 ms
16,192 KB
testcase_19 AC 59 ms
11,136 KB
testcase_20 AC 1,373 ms
20,816 KB
testcase_21 AC 372 ms
13,696 KB
testcase_22 AC 197 ms
12,084 KB
testcase_23 AC 952 ms
18,780 KB
testcase_24 AC 973 ms
18,520 KB
testcase_25 AC 1,173 ms
18,648 KB
testcase_26 AC 1,433 ms
20,564 KB
testcase_27 AC 1,296 ms
19,544 KB
testcase_28 AC 983 ms
17,884 KB
testcase_29 AC 847 ms
17,112 KB
testcase_30 AC 1,175 ms
19,284 KB
testcase_31 AC 634 ms
16,088 KB
testcase_32 AC 1,407 ms
19,672 KB
testcase_33 AC 1,113 ms
19,284 KB
testcase_34 AC 1,444 ms
21,464 KB
testcase_35 AC 89 ms
14,296 KB
testcase_36 AC 81 ms
14,296 KB
testcase_37 AC 1,816 ms
23,896 KB
testcase_38 AC 278 ms
15,832 KB
testcase_39 AC 234 ms
15,704 KB
testcase_40 AC 170 ms
15,832 KB
testcase_41 AC 198 ms
15,828 KB
testcase_42 TLE -
testcase_43 AC 1,796 ms
23,768 KB
testcase_44 AC 96 ms
14,292 KB
testcase_45 AC 1,342 ms
19,796 KB
testcase_46 AC 1,323 ms
19,924 KB
testcase_47 AC 236 ms
15,832 KB
testcase_48 AC 211 ms
15,832 KB
testcase_49 AC 1,404 ms
19,920 KB
testcase_50 AC 1,365 ms
19,928 KB
testcase_51 AC 1,371 ms
19,928 KB
testcase_52 AC 1,313 ms
19,932 KB
testcase_53 AC 1,259 ms
19,928 KB
testcase_54 AC 854 ms
17,252 KB
testcase_55 AC 763 ms
16,544 KB
testcase_56 AC 569 ms
16,084 KB
testcase_57 AC 685 ms
15,836 KB
testcase_58 AC 519 ms
16,264 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=-1
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"

   
print(max(score(A),score(B)))
0