結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー hedwig100
提出日時 2020-04-13 15:22:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 971 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-09-25 01:15:39
合計ジャッジ時間 39,761 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 57 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from heapq import heapify,heappush,heappop
from copy import deepcopy

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

    for index in range(q):
        t = query[index]
        r = 0
        tot = 0
        ans = 0
        cnt = 0
        for l in range(n):
            while r < n and tot + a[r] <= t:
                if s[r] == 'E':
                    cnt += 1
                tot += a[r]
                r += 1
            
            ans = max(ans,cnt)
            if l == r:
                r += 1
                cnt = 0
                tot = 0
            else:
                if s[l] == 'E':
                    cnt -= 1
                tot -= a[l]
        
        print(ans)

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