結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー timi
提出日時 2020-10-26 13:10:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 18,084 KB
最終ジャッジ日時 2024-07-21 21:20:29
合計ジャッジ時間 12,811 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other AC * 2 WA * 4 TLE * 3 -- * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
A=list(map(int, input().split()))
Q=int(input())
K=list(map(int, input().split()))
E=[0]
e=0
if S=='W'*N:
    for i in range(Q):
        print(0)
    exit()
for i in S:
    if i=='E':
        e+=1 
    E.append(e)
for i in range(Q):
    hp=K[i]
    l,r=0,0
    hp-=A[0]
    e=E[r+1]-E[l]
    ans,d=0,0
    if hp>=0 and S[0]=='E':
        d+=1
        ans=1
    while r<N:
        if hp<0:
            l+=1
            hp+=A[l-1]
            if S[l-1]=='E':
                d-=1
        else:
            r+=1
            hp-=A[r]
            if S[r]=='E':
                d+=1
        if hp>=0:
            ans=max(d,ans)
            if r==N-1:
                print(ans)
                break
0