結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー yuly3
提出日時 2020-01-07 15:39:09
言語 Nim
(2.2.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 5,415 ms
コンパイル使用メモリ 67,004 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-23 01:00:22
合計ジャッジ時間 8,056 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils, strutils

proc solve() =
    var
        N = stdin.readLine.parseInt()
        S = stdin.readLine
        A = stdin.readLine.split.map(parseInt)
        Q = stdin.readLine.parseInt
        K = stdin.readLine.split.map(parseInt)

    var e_acc = @[0]
    for si in S:
        if si == 'E':
            e_acc.add(e_acc[e_acc.len-1] + 1)
        else:
            e_acc.add(e_acc[e_acc.len-1])
    
    for ki in K:
        var
            r = 0
            ans = 0
            k = ki
        for l in 0..<N:
            while r < N and 0 <= k - A[r]:
                k -= A[r]
                inc r
            ans = max(ans, e_acc[r] - e_acc[l])
            if l == r:
                inc r
            else:
                k += A[l]
        echo ans


solve()
0