結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
コンテスト
ユーザー roaris
提出日時 2019-12-12 16:48:06
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 529 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 189 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 81,792 KB
最終ジャッジ日時 2026-04-04 10:45:50
合計ジャッジ時間 5,352 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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