結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー neterukunneterukun
提出日時 2019-11-29 22:53:53
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,093 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 78,504 KB
最終ジャッジ日時 2023-10-12 06:31:08
合計ジャッジ時間 14,498 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
76,700 KB
testcase_01 AC 197 ms
77,564 KB
testcase_02 AC 99 ms
76,764 KB
testcase_03 AC 142 ms
77,124 KB
testcase_04 AC 173 ms
77,648 KB
testcase_05 AC 97 ms
76,660 KB
testcase_06 AC 223 ms
77,584 KB
testcase_07 AC 222 ms
78,012 KB
testcase_08 AC 383 ms
78,396 KB
testcase_09 AC 267 ms
77,640 KB
testcase_10 AC 309 ms
77,604 KB
testcase_11 AC 358 ms
77,364 KB
testcase_12 AC 72 ms
71,312 KB
testcase_13 AC 71 ms
71,268 KB
testcase_14 AC 72 ms
71,204 KB
testcase_15 AC 73 ms
71,204 KB
testcase_16 AC 78 ms
71,336 KB
testcase_17 AC 1,093 ms
78,196 KB
testcase_18 AC 175 ms
77,576 KB
testcase_19 AC 288 ms
78,176 KB
testcase_20 AC 237 ms
78,172 KB
testcase_21 AC 111 ms
76,752 KB
testcase_22 AC 94 ms
76,128 KB
testcase_23 AC 83 ms
75,932 KB
testcase_24 AC 88 ms
76,260 KB
testcase_25 AC 90 ms
76,316 KB
testcase_26 AC 84 ms
76,400 KB
testcase_27 AC 77 ms
75,720 KB
testcase_28 AC 82 ms
76,164 KB
testcase_29 AC 88 ms
76,316 KB
testcase_30 AC 84 ms
76,172 KB
testcase_31 AC 82 ms
75,968 KB
testcase_32 AC 88 ms
76,460 KB
testcase_33 AC 222 ms
78,444 KB
testcase_34 AC 330 ms
78,256 KB
testcase_35 AC 297 ms
77,600 KB
testcase_36 AC 143 ms
77,452 KB
testcase_37 AC 218 ms
77,608 KB
testcase_38 AC 210 ms
76,980 KB
testcase_39 AC 332 ms
77,828 KB
testcase_40 AC 357 ms
78,020 KB
testcase_41 AC 353 ms
77,920 KB
testcase_42 AC 287 ms
78,080 KB
testcase_43 AC 366 ms
77,668 KB
testcase_44 AC 188 ms
77,556 KB
testcase_45 AC 372 ms
78,504 KB
testcase_46 AC 118 ms
77,028 KB
testcase_47 AC 192 ms
77,484 KB
testcase_48 AC 175 ms
77,732 KB
testcase_49 AC 186 ms
77,428 KB
testcase_50 AC 219 ms
77,640 KB
testcase_51 AC 241 ms
77,752 KB
testcase_52 AC 236 ms
77,632 KB
testcase_53 AC 335 ms
78,132 KB
testcase_54 AC 148 ms
77,672 KB
testcase_55 AC 109 ms
76,828 KB
testcase_56 AC 267 ms
77,644 KB
testcase_57 AC 224 ms
78,456 KB
testcase_58 AC 79 ms
71,132 KB
testcase_59 AC 77 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
a = list(map(int, input().split()))
q = int(input())
query = list(map(int, input().split()))

ruiseki = [0] * (n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + (1 if s[i] == "E" else 0)

# ダブリング
log_size = n.bit_length()
double = [[0] * n for i in range(log_size)]
INF = 10**18
for i in range(n):
    double[0][i] = a[i]
for k in range(1, log_size):
    for i in range(n):
        if i+2**(k-1) < n:
            double[k][i] = double[k-1][i+2**(k-1)] + double[k-1][i]
        else:
            double[k][i] = INF

for qi in range(q):
    ans = 0
    for ni in range(n):
        ans_tmp = 0
        ans_num = 0
        k = log_size - 1
        i = ni
        while True:
            if k < 0 or i == n:
                break
            if ans_num + double[k][i] <= query[qi]:
                ans_num += double[k][i]
                i += 2**k
                ans_tmp += 2**k
            k -= 1
        ans_tmp = ruiseki[i] - ruiseki[ni]
        ans = max(ans, ans_tmp)
    print(ans)
0