結果

問題 No.2276 I Want AC
ユーザー kuro_Bkuro_B
提出日時 2023-05-10 16:17:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,957 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 116,124 KB
最終ジャッジ日時 2024-05-05 03:56:49
合計ジャッジ時間 17,132 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
83,456 KB
testcase_01 AC 127 ms
83,456 KB
testcase_02 AC 120 ms
83,456 KB
testcase_03 AC 124 ms
83,456 KB
testcase_04 AC 123 ms
83,456 KB
testcase_05 AC 120 ms
83,456 KB
testcase_06 AC 120 ms
83,072 KB
testcase_07 AC 124 ms
83,584 KB
testcase_08 AC 121 ms
83,328 KB
testcase_09 AC 123 ms
83,456 KB
testcase_10 AC 122 ms
83,200 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 161 ms
94,020 KB
testcase_36 AC 151 ms
93,952 KB
testcase_37 AC 340 ms
115,312 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 188 ms
103,428 KB
testcase_41 AC 197 ms
103,812 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 170 ms
100,352 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 189 ms
101,900 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 AC 280 ms
109,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

###スニペット始まり###
import sys, re
from copy import copy, deepcopy
from math import ceil, floor, sqrt,factorial, gcd, pi, degrees, radians, sin, asin, cos, acos, tan, atan2
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations, accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from string import ascii_uppercase, ascii_lowercase
from decimal import Decimal, ROUND_HALF_UP #四捨五入用

def input(): return sys.stdin.readline().rstrip('\n')
#easy-testのpypyでは再帰数を下げる。
if __file__=='prog.py':
    sys.setrecursionlimit(10**5)
else:
    sys.setrecursionlimit(10**6)

def lcm(a, b): return a * b // gcd(a, b)

#3つ以上の最大公約数/最小公倍数。Nを要素数、Mを数値の大きさとして、O(NlogM)
def gcd_v2(l: list): return reduce(gcd, l)
def lcm_v2(l: list): return reduce(lcm, l)

#nPk
def nPk(n, k): return factorial(n) // factorial(n - k)

#逆元
def modinv(a, mod=10**9+7): return pow(a, mod-2, mod)
INF = float('inf')
MOD = 10 ** 9 + 7
###スニペット終わり###

N=int(input())
S=list(input())

hatena_idx=[]
for i, s in enumerate(S):
    if s=='?':
        hatena_idx.append(i)

max_=-INF
def is_ok(mid):
    global max_
    s=S.copy()
    for i, idx in enumerate(hatena_idx):
        if i<mid:
            s[idx]='A'
        else:
            s[idx]='C'

    counter=Counter()

    cnt=0
    for i in range(N):
        if s[-(i+1)]=='A':
            cnt+=counter['C']
        counter[s[-(i+1)]]+=1
    
    max_=max(cnt,max_)
    return max_==cnt

def meguru_bisect(ng, ok):

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            # print(mid)
            ok = mid
        else:
            ng = mid
    return ok

meguru_bisect(len(hatena_idx)+1, -1)
print(max_)
0