結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー hiragnhiragn
提出日時 2022-12-02 14:55:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,005 ms / 2,000 ms
コード長 1,130 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-17 23:16:48
合計ジャッジ時間 23,344 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
11,136 KB
testcase_01 AC 118 ms
11,008 KB
testcase_02 AC 134 ms
10,880 KB
testcase_03 AC 269 ms
11,264 KB
testcase_04 AC 474 ms
11,136 KB
testcase_05 AC 234 ms
11,008 KB
testcase_06 AC 265 ms
11,136 KB
testcase_07 AC 331 ms
11,136 KB
testcase_08 AC 950 ms
11,392 KB
testcase_09 AC 543 ms
11,264 KB
testcase_10 AC 586 ms
11,264 KB
testcase_11 AC 897 ms
11,520 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 26 ms
10,880 KB
testcase_14 AC 28 ms
10,752 KB
testcase_15 AC 28 ms
10,880 KB
testcase_16 AC 29 ms
10,752 KB
testcase_17 AC 1,005 ms
11,392 KB
testcase_18 AC 553 ms
11,136 KB
testcase_19 AC 247 ms
11,136 KB
testcase_20 AC 765 ms
11,264 KB
testcase_21 AC 42 ms
10,880 KB
testcase_22 AC 208 ms
11,008 KB
testcase_23 AC 28 ms
11,008 KB
testcase_24 AC 31 ms
11,008 KB
testcase_25 AC 32 ms
10,880 KB
testcase_26 AC 36 ms
10,880 KB
testcase_27 AC 28 ms
10,752 KB
testcase_28 AC 33 ms
10,880 KB
testcase_29 AC 36 ms
11,008 KB
testcase_30 AC 36 ms
10,752 KB
testcase_31 AC 36 ms
11,008 KB
testcase_32 AC 40 ms
11,008 KB
testcase_33 AC 909 ms
11,392 KB
testcase_34 AC 632 ms
11,264 KB
testcase_35 AC 694 ms
11,264 KB
testcase_36 AC 294 ms
11,136 KB
testcase_37 AC 762 ms
11,264 KB
testcase_38 AC 279 ms
11,136 KB
testcase_39 AC 673 ms
11,392 KB
testcase_40 AC 700 ms
11,264 KB
testcase_41 AC 717 ms
11,392 KB
testcase_42 AC 790 ms
11,264 KB
testcase_43 AC 731 ms
11,392 KB
testcase_44 AC 96 ms
11,136 KB
testcase_45 AC 1,005 ms
11,392 KB
testcase_46 AC 54 ms
11,136 KB
testcase_47 AC 193 ms
11,136 KB
testcase_48 AC 581 ms
11,136 KB
testcase_49 AC 220 ms
11,136 KB
testcase_50 AC 555 ms
11,264 KB
testcase_51 AC 456 ms
11,136 KB
testcase_52 AC 418 ms
11,136 KB
testcase_53 AC 979 ms
11,264 KB
testcase_54 AC 405 ms
11,136 KB
testcase_55 AC 45 ms
11,008 KB
testcase_56 AC 640 ms
11,392 KB
testcase_57 AC 352 ms
11,136 KB
testcase_58 AC 30 ms
10,752 KB
testcase_59 AC 26 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
from collections import defaultdict
import bisect


def main():
    n = int(input())
    s = input()
    a = list(map(int, input().split()))  # 敵,壁の耐久力
    q = int(input())
    k = list(map(int, input().split()))  # 攻撃力

    # 自明な場合
    if s == 'W' * n:
        for _ in range(q):
            print(0)
        exit()

    # 非自明な場合
    enemy = [0]  # 敵数の累積和
    e = 0
    for i in s:
        if i == 'E':
            e += 1
        enemy.append(e)

    acc = [0] + list(accumulate(a))  # 攻撃力の累積和

    # d[x]:敵をx匹倒すのに必要な攻撃力
    offensive_power = defaultdict(lambda: 10 ** 13)
    for left in range(n):
        for right in range(left, n):
            e = enemy[right + 1] - enemy[left]
            op = acc[right + 1] - acc[left]
            offensive_power[e] = min(offensive_power[e], op)

    ans = []
    for i in range(1, s.count('E') + 1):
        ans.append(offensive_power[i])

    for kk in k:
        res = bisect.bisect_right(ans, kk)
        print(res)


if __name__ == "__main__":
    main()
0