結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー Yukino DX.
提出日時 2023-11-23 22:06:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,696 KB
最終ジャッジ日時 2024-09-26 08:21:07
合計ジャッジ時間 10,097 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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

for ki in k:
    q = deque()
    sum, cnt, ans = 0, 0, 0
    for i in range(n):
        q.append(i)
        if s[i] == "E":
            cnt += 1
        sum += a[i]

        while sum > ki and q:
            id = q.popleft()
            sum -= a[id]
            if s[id] == "E":
                cnt -= 1

        ans = max(ans, cnt)

    print(ans)
0