結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー roaris
提出日時 2019-12-12 16:48:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 81,392 KB
実行使用メモリ 76,720 KB
最終ジャッジ日時 2024-09-14 06:04:29
合計ジャッジ時間 7,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(K):
    r = 0
    res = 0
    k = K

    for l in range(N):
        while r<N and k-A[r]>=0:
            k -= A[r]
            r += 1
        
        res = max(res, acc[r]-acc[l])
        
        if l==r:
            r += 1
        else:
            k += A[l]
    
    return res
            
N = int(input())
S = input()
A = list(map(int, input().split()))
Q = int(input())
K = list(map(int, input().split()))
acc = [0]

for Si in S:
    acc.append(acc[-1]+(1 if Si=='E' else 0))
    
for Ki in K:
    print(calc(Ki))
0