結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー tails1434tails1434
提出日時 2019-12-23 21:30:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 81,452 KB
実行使用メモリ 74,792 KB
最終ジャッジ日時 2023-10-19 04:24:04
合計ジャッジ時間 6,208 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
68,356 KB
testcase_01 AC 67 ms
68,472 KB
testcase_02 AC 51 ms
61,700 KB
testcase_03 AC 60 ms
66,024 KB
testcase_04 AC 86 ms
68,264 KB
testcase_05 AC 52 ms
61,888 KB
testcase_06 AC 68 ms
68,512 KB
testcase_07 AC 83 ms
70,792 KB
testcase_08 AC 97 ms
73,260 KB
testcase_09 AC 75 ms
70,724 KB
testcase_10 AC 77 ms
72,780 KB
testcase_11 AC 94 ms
72,836 KB
testcase_12 AC 39 ms
53,324 KB
testcase_13 AC 40 ms
53,324 KB
testcase_14 AC 40 ms
53,324 KB
testcase_15 AC 40 ms
53,324 KB
testcase_16 AC 40 ms
53,324 KB
testcase_17 AC 90 ms
70,764 KB
testcase_18 AC 76 ms
68,280 KB
testcase_19 AC 73 ms
70,568 KB
testcase_20 AC 73 ms
68,276 KB
testcase_21 AC 56 ms
63,792 KB
testcase_22 AC 51 ms
61,576 KB
testcase_23 AC 41 ms
53,324 KB
testcase_24 AC 48 ms
61,332 KB
testcase_25 AC 46 ms
59,280 KB
testcase_26 AC 45 ms
59,280 KB
testcase_27 AC 44 ms
59,264 KB
testcase_28 AC 44 ms
59,264 KB
testcase_29 AC 48 ms
61,528 KB
testcase_30 AC 46 ms
59,280 KB
testcase_31 AC 45 ms
59,264 KB
testcase_32 AC 47 ms
59,280 KB
testcase_33 AC 73 ms
68,284 KB
testcase_34 AC 78 ms
72,772 KB
testcase_35 AC 78 ms
72,772 KB
testcase_36 AC 61 ms
64,116 KB
testcase_37 AC 84 ms
68,356 KB
testcase_38 AC 70 ms
70,568 KB
testcase_39 AC 97 ms
73,012 KB
testcase_40 AC 94 ms
72,844 KB
testcase_41 AC 91 ms
72,844 KB
testcase_42 AC 82 ms
72,836 KB
testcase_43 AC 96 ms
73,492 KB
testcase_44 AC 70 ms
70,576 KB
testcase_45 AC 86 ms
73,848 KB
testcase_46 AC 62 ms
66,080 KB
testcase_47 AC 69 ms
70,576 KB
testcase_48 AC 67 ms
66,176 KB
testcase_49 AC 72 ms
68,520 KB
testcase_50 AC 69 ms
68,292 KB
testcase_51 AC 73 ms
70,724 KB
testcase_52 AC 74 ms
70,724 KB
testcase_53 AC 101 ms
74,792 KB
testcase_54 AC 72 ms
66,236 KB
testcase_55 AC 50 ms
61,588 KB
testcase_56 AC 89 ms
72,836 KB
testcase_57 AC 72 ms
70,724 KB
testcase_58 AC 40 ms
53,324 KB
testcase_59 AC 39 ms
53,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
from bisect import bisect_right

def main():
    N = int(input())
    S = input()
    A = list(map(int, input().split()))
    Q = int(input())
    K = list(map(int, input().split()))
    B = [0] + list(accumulate(A))
    C = [0] * (N + 1)
    for i in range(N):
        if S[i] == 'E':
            C[i+1] = C[i] + 1
        else:
            C[i+1] = C[i]

    P = [float('inf')] * (max(C) + 1)
    for i in range(N+1):
        for j in range(i+1,N+1):
            P[C[j]-C[i]] = min(P[C[j]-C[i]], B[j]-B[i])
    for k in K:
        d = bisect_right(P,k)
        print(max(0,d-1)) 



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