結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー maspymaspy
提出日時 2020-02-02 15:46:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 910 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 12,048 KB
実行使用メモリ 42,460 KB
最終ジャッジ日時 2023-10-19 01:07:19
合計ジャッジ時間 42,556 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 492 ms
42,460 KB
testcase_01 AC 537 ms
42,460 KB
testcase_02 AC 537 ms
42,460 KB
testcase_03 AC 597 ms
42,460 KB
testcase_04 AC 699 ms
42,460 KB
testcase_05 AC 588 ms
42,460 KB
testcase_06 AC 602 ms
42,460 KB
testcase_07 AC 631 ms
42,460 KB
testcase_08 AC 907 ms
42,460 KB
testcase_09 AC 739 ms
42,460 KB
testcase_10 AC 757 ms
42,460 KB
testcase_11 AC 863 ms
42,460 KB
testcase_12 AC 485 ms
42,460 KB
testcase_13 AC 486 ms
42,460 KB
testcase_14 AC 479 ms
42,460 KB
testcase_15 AC 488 ms
42,460 KB
testcase_16 AC 489 ms
42,460 KB
testcase_17 AC 903 ms
42,460 KB
testcase_18 AC 729 ms
42,460 KB
testcase_19 AC 591 ms
42,460 KB
testcase_20 AC 817 ms
42,460 KB
testcase_21 AC 505 ms
42,460 KB
testcase_22 AC 578 ms
42,460 KB
testcase_23 AC 488 ms
42,460 KB
testcase_24 AC 496 ms
42,460 KB
testcase_25 AC 496 ms
42,460 KB
testcase_26 AC 484 ms
42,460 KB
testcase_27 AC 483 ms
42,460 KB
testcase_28 AC 490 ms
42,460 KB
testcase_29 AC 481 ms
42,460 KB
testcase_30 AC 484 ms
42,460 KB
testcase_31 AC 485 ms
42,460 KB
testcase_32 AC 498 ms
42,460 KB
testcase_33 AC 881 ms
42,460 KB
testcase_34 AC 764 ms
42,460 KB
testcase_35 AC 799 ms
42,460 KB
testcase_36 AC 629 ms
42,460 KB
testcase_37 AC 816 ms
42,460 KB
testcase_38 AC 616 ms
42,460 KB
testcase_39 AC 783 ms
42,460 KB
testcase_40 AC 796 ms
42,460 KB
testcase_41 AC 815 ms
42,460 KB
testcase_42 AC 817 ms
42,460 KB
testcase_43 AC 804 ms
42,460 KB
testcase_44 AC 524 ms
42,460 KB
testcase_45 AC 910 ms
42,460 KB
testcase_46 AC 505 ms
42,460 KB
testcase_47 AC 574 ms
42,460 KB
testcase_48 AC 776 ms
42,460 KB
testcase_49 AC 588 ms
42,460 KB
testcase_50 AC 732 ms
42,460 KB
testcase_51 AC 684 ms
42,460 KB
testcase_52 AC 669 ms
42,460 KB
testcase_53 AC 907 ms
42,460 KB
testcase_54 AC 670 ms
42,460 KB
testcase_55 AC 509 ms
42,460 KB
testcase_56 AC 774 ms
42,460 KB
testcase_57 AC 635 ms
42,460 KB
testcase_58 AC 490 ms
42,460 KB
testcase_59 AC 490 ms
42,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.frombuffer(readline().rstrip(),'S1') == b'E'
A = np.array(readline().split(),np.int64)
Q = int(readline())
K = np.array(read().split(),np.int64)

INF = 10 ** 18
min_power = [INF] * (N+1)

for L in range(N):
    power = A[L:].cumsum()
    n_enemy = np.cumsum(S[L:])
    for p,n in zip(power.tolist(), n_enemy.tolist()):
        if min_power[n] > p:
            min_power[n] = p

for n in range(N-1,-1,-1):
    if min_power[n] > min_power[n+1]:
        min_power[n] = min_power[n+1]
min_power[0] = 0

answer = np.searchsorted(min_power, K, 'right') - 1
print('\n'.join(answer.astype(str)))
0