結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー FromBooskaFromBooska
提出日時 2023-09-25 11:18:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 816 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 78,212 KB
最終ジャッジ日時 2023-09-25 11:18:33
合計ジャッジ時間 24,313 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
77,164 KB
testcase_01 AC 244 ms
77,480 KB
testcase_02 AC 105 ms
76,608 KB
testcase_03 AC 267 ms
77,248 KB
testcase_04 AC 308 ms
77,540 KB
testcase_05 AC 110 ms
76,888 KB
testcase_06 AC 444 ms
77,332 KB
testcase_07 AC 389 ms
77,484 KB
testcase_08 AC 816 ms
77,852 KB
testcase_09 AC 522 ms
77,556 KB
testcase_10 AC 645 ms
77,644 KB
testcase_11 AC 736 ms
77,568 KB
testcase_12 AC 74 ms
71,020 KB
testcase_13 AC 75 ms
71,196 KB
testcase_14 AC 75 ms
71,304 KB
testcase_15 AC 74 ms
71,060 KB
testcase_16 AC 90 ms
71,168 KB
testcase_17 AC 525 ms
77,840 KB
testcase_18 AC 229 ms
77,488 KB
testcase_19 AC 466 ms
77,352 KB
testcase_20 AC 360 ms
77,440 KB
testcase_21 AC 126 ms
77,136 KB
testcase_22 AC 97 ms
76,280 KB
testcase_23 AC 89 ms
75,864 KB
testcase_24 AC 91 ms
76,356 KB
testcase_25 AC 93 ms
76,492 KB
testcase_26 AC 84 ms
75,696 KB
testcase_27 AC 79 ms
75,092 KB
testcase_28 AC 92 ms
76,356 KB
testcase_29 AC 96 ms
76,584 KB
testcase_30 AC 89 ms
75,864 KB
testcase_31 AC 88 ms
75,864 KB
testcase_32 AC 94 ms
76,496 KB
testcase_33 AC 392 ms
77,336 KB
testcase_34 AC 648 ms
77,628 KB
testcase_35 AC 565 ms
77,552 KB
testcase_36 AC 204 ms
77,552 KB
testcase_37 AC 397 ms
77,480 KB
testcase_38 AC 395 ms
77,440 KB
testcase_39 AC 680 ms
77,788 KB
testcase_40 AC 713 ms
78,212 KB
testcase_41 AC 721 ms
77,780 KB
testcase_42 AC 541 ms
77,552 KB
testcase_43 AC 753 ms
77,800 KB
testcase_44 AC 286 ms
77,600 KB
testcase_45 AC 729 ms
77,784 KB
testcase_46 AC 153 ms
77,124 KB
testcase_47 AC 326 ms
77,544 KB
testcase_48 AC 277 ms
77,840 KB
testcase_49 AC 306 ms
77,436 KB
testcase_50 AC 373 ms
77,392 KB
testcase_51 AC 421 ms
77,600 KB
testcase_52 AC 444 ms
77,440 KB
testcase_53 AC 642 ms
77,772 KB
testcase_54 AC 207 ms
77,552 KB
testcase_55 AC 113 ms
77,004 KB
testcase_56 AC 499 ms
77,452 KB
testcase_57 AC 360 ms
77,604 KB
testcase_58 AC 72 ms
71,224 KB
testcase_59 AC 73 ms
71,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 累積和をHP分、敵カウント分
# k以下の探索はbisect
# これで間に合うか?

N = int(input())
S = input()
A = list(map(int, input().split()))

HP_cumu = [0]
hp_temp = 0
enemy_cumu = [0]
enemy_temp = 0
for i in range(N):
    hp_temp += A[i]
    HP_cumu.append(hp_temp)
    if S[i] == 'E':
        enemy_temp += 1
    enemy_cumu.append(enemy_temp)
    
Q = int(input())
K = list(map(int, input().split()))
from bisect import *
for q in range(Q):
    k = K[q]
    ans = 0
    for i in range(N):
        start = HP_cumu[i]
        target = start+k
        idx = bisect_left(HP_cumu, target+1)-1
        calc = enemy_cumu[idx]-enemy_cumu[i]
        ans = max(ans, calc)
    print(ans)

0