結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー NoneNone
提出日時 2021-10-31 12:29:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 716 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,124 KB
最終ジャッジ日時 2024-04-17 05:16:09
合計ジャッジ時間 18,491 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
75,904 KB
testcase_01 AC 211 ms
76,416 KB
testcase_02 AC 88 ms
75,520 KB
testcase_03 AC 226 ms
76,160 KB
testcase_04 AC 259 ms
76,544 KB
testcase_05 AC 95 ms
75,904 KB
testcase_06 AC 350 ms
76,160 KB
testcase_07 AC 332 ms
76,800 KB
testcase_08 AC 671 ms
77,124 KB
testcase_09 AC 441 ms
76,288 KB
testcase_10 AC 531 ms
76,452 KB
testcase_11 AC 610 ms
76,928 KB
testcase_12 AC 42 ms
51,456 KB
testcase_13 AC 42 ms
51,968 KB
testcase_14 AC 43 ms
51,968 KB
testcase_15 AC 45 ms
51,968 KB
testcase_16 AC 43 ms
51,840 KB
testcase_17 AC 716 ms
76,672 KB
testcase_18 AC 208 ms
76,312 KB
testcase_19 AC 409 ms
76,288 KB
testcase_20 AC 317 ms
76,340 KB
testcase_21 AC 115 ms
76,544 KB
testcase_22 AC 84 ms
75,264 KB
testcase_23 AC 75 ms
68,480 KB
testcase_24 AC 75 ms
75,392 KB
testcase_25 AC 78 ms
75,648 KB
testcase_26 AC 60 ms
63,360 KB
testcase_27 AC 51 ms
59,136 KB
testcase_28 AC 73 ms
72,448 KB
testcase_29 AC 81 ms
75,776 KB
testcase_30 AC 79 ms
72,960 KB
testcase_31 AC 69 ms
69,888 KB
testcase_32 AC 80 ms
75,520 KB
testcase_33 AC 336 ms
76,072 KB
testcase_34 AC 535 ms
76,352 KB
testcase_35 AC 480 ms
76,800 KB
testcase_36 AC 181 ms
76,544 KB
testcase_37 AC 328 ms
76,288 KB
testcase_38 AC 331 ms
76,288 KB
testcase_39 AC 547 ms
76,800 KB
testcase_40 AC 593 ms
76,336 KB
testcase_41 AC 578 ms
76,860 KB
testcase_42 AC 472 ms
76,672 KB
testcase_43 AC 609 ms
76,928 KB
testcase_44 AC 263 ms
76,288 KB
testcase_45 AC 600 ms
76,340 KB
testcase_46 AC 143 ms
76,928 KB
testcase_47 AC 292 ms
76,544 KB
testcase_48 AC 249 ms
76,440 KB
testcase_49 AC 274 ms
75,904 KB
testcase_50 AC 309 ms
76,328 KB
testcase_51 AC 366 ms
76,416 KB
testcase_52 AC 355 ms
76,288 KB
testcase_53 AC 535 ms
76,712 KB
testcase_54 AC 182 ms
76,544 KB
testcase_55 AC 101 ms
75,776 KB
testcase_56 AC 441 ms
76,800 KB
testcase_57 AC 319 ms
76,192 KB
testcase_58 AC 43 ms
51,584 KB
testcase_59 AC 42 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok

##############################################################

import sys
input = sys.stdin.readline



N=int(input())
S=input().rstrip()
A=list(map(int, input().split()))
Q=int(input())
K=list(map(int, input().split()))
SS=[0]
for s in S:
    SS.append(SS[-1]+(s=="E"))
SA=[0]
for a in A:
    SA.append(SA[-1]+a)
for k in K:
    res=0
    for i in range(N):
        def test(x):
            return SA[x]-SA[i]<=k
        r=binary_search_int(i,N+1,test)
        res=max(SS[r]-SS[i],res)
    print(res)
0