結果

問題 No.2276 I Want AC
ユーザー FromBooskaFromBooska
提出日時 2023-04-21 22:41:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 67,456 KB
最終ジャッジ日時 2024-04-24 08:48:04
合計ジャッジ時間 20,434 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,840 KB
testcase_01 AC 33 ms
51,840 KB
testcase_02 AC 34 ms
51,840 KB
testcase_03 AC 34 ms
51,712 KB
testcase_04 AC 34 ms
51,712 KB
testcase_05 AC 33 ms
51,968 KB
testcase_06 AC 35 ms
51,584 KB
testcase_07 AC 34 ms
51,968 KB
testcase_08 AC 34 ms
51,840 KB
testcase_09 AC 40 ms
51,840 KB
testcase_10 AC 40 ms
51,712 KB
testcase_11 AC 261 ms
65,280 KB
testcase_12 WA -
testcase_13 AC 234 ms
65,408 KB
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 AC 607 ms
65,920 KB
testcase_24 AC 631 ms
65,664 KB
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 44 ms
59,008 KB
testcase_36 AC 40 ms
58,880 KB
testcase_37 AC 463 ms
63,616 KB
testcase_38 AC 68 ms
62,080 KB
testcase_39 AC 55 ms
60,800 KB
testcase_40 AC 63 ms
61,824 KB
testcase_41 AC 74 ms
62,080 KB
testcase_42 AC 442 ms
65,408 KB
testcase_43 AC 443 ms
65,280 KB
testcase_44 AC 43 ms
59,392 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 78 ms
62,592 KB
testcase_48 AC 73 ms
62,976 KB
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 WA -
testcase_58 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# ?の数を数えて、前半何個までをAとするかで全探索してみるか

N = int(input())
S = input()
q_count = S.count('?')

if q_count == 0:
    subans = 0
    A_count = 0
    used = 0
    for i in range(N):
        if S[i] == 'A':
            A_count += 1
        elif S[i] == 'C':
            subans += A_count
    print(subans)
    exit()

ans = 0
width = 100
for q in range(max(0, (q_count//2)-width), min(q_count, (q_count//2)+width)+1):
    subans = 0
    A_count = 0
    used = 0
    for i in range(N):
        if S[i] == 'A':
            A_count += 1
        elif S[i] == 'C':
            subans += A_count
        elif S[i] == '?':
            if used < q:
                # treat as A
                used += 1
                A_count += 1
            else: 
                # treat as C
                subans += A_count
    #print('q', q, 'subans', subans)
    ans = max(ans, subans)
print(ans)





0