結果

問題 No.2276 I Want AC
ユーザー ShirotsumeShirotsume
提出日時 2023-04-21 22:05:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-04-24 08:12:56
合計ジャッジ時間 5,399 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,760 KB
testcase_01 AC 40 ms
53,632 KB
testcase_02 AC 39 ms
53,632 KB
testcase_03 AC 40 ms
53,632 KB
testcase_04 AC 40 ms
53,504 KB
testcase_05 AC 40 ms
53,504 KB
testcase_06 AC 42 ms
53,888 KB
testcase_07 AC 39 ms
53,248 KB
testcase_08 AC 40 ms
53,632 KB
testcase_09 AC 41 ms
53,632 KB
testcase_10 AC 40 ms
53,632 KB
testcase_11 AC 64 ms
71,808 KB
testcase_12 AC 80 ms
75,776 KB
testcase_13 AC 66 ms
71,552 KB
testcase_14 AC 63 ms
67,072 KB
testcase_15 AC 67 ms
75,520 KB
testcase_16 AC 72 ms
75,648 KB
testcase_17 AC 73 ms
75,904 KB
testcase_18 AC 71 ms
76,032 KB
testcase_19 AC 58 ms
64,384 KB
testcase_20 AC 76 ms
75,904 KB
testcase_21 AC 68 ms
73,088 KB
testcase_22 AC 65 ms
67,712 KB
testcase_23 AC 87 ms
75,776 KB
testcase_24 AC 84 ms
75,904 KB
testcase_25 AC 84 ms
76,160 KB
testcase_26 AC 77 ms
76,032 KB
testcase_27 AC 74 ms
75,776 KB
testcase_28 AC 72 ms
75,776 KB
testcase_29 AC 70 ms
75,520 KB
testcase_30 AC 72 ms
75,648 KB
testcase_31 AC 69 ms
76,032 KB
testcase_32 AC 75 ms
75,648 KB
testcase_33 AC 74 ms
76,032 KB
testcase_34 AC 73 ms
75,904 KB
testcase_35 AC 50 ms
60,672 KB
testcase_36 AC 51 ms
60,928 KB
testcase_37 AC 56 ms
62,464 KB
testcase_38 AC 71 ms
76,160 KB
testcase_39 AC 67 ms
76,160 KB
testcase_40 AC 64 ms
76,160 KB
testcase_41 AC 68 ms
76,032 KB
testcase_42 AC 68 ms
75,776 KB
testcase_43 AC 72 ms
76,160 KB
testcase_44 AC 71 ms
75,904 KB
testcase_45 AC 71 ms
75,648 KB
testcase_46 AC 69 ms
76,416 KB
testcase_47 AC 70 ms
75,776 KB
testcase_48 AC 70 ms
76,288 KB
testcase_49 AC 73 ms
75,776 KB
testcase_50 AC 73 ms
76,416 KB
testcase_51 AC 72 ms
75,776 KB
testcase_52 AC 75 ms
75,904 KB
testcase_53 AC 75 ms
76,032 KB
testcase_54 AC 73 ms
75,904 KB
testcase_55 AC 71 ms
75,776 KB
testcase_56 AC 72 ms
76,160 KB
testcase_57 AC 67 ms
75,776 KB
testcase_58 AC 70 ms
76,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()
s = input()
counta = 0
countc = 0
ans = 0
for v in s:
    if v == 'C' or v == '?':
        ans += counta
        countc += 1
    else:
        counta += 1

counta = 0
now = ans
for v in s:
    if v == 'A':
        counta += 1
    if v == 'C':
        countc -= 1
    if v == '?':
        countc -= 1
        now += countc
        now -= counta
        ans = max(ans, now)
        counta += 1
print(ans)

0