結果
問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
ユーザー |
|
提出日時 | 2021-01-16 10:35:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 264 ms / 2,000 ms |
コード長 | 1,269 bytes |
コンパイル時間 | 434 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 90,496 KB |
最終ジャッジ日時 | 2024-11-27 10:32:47 |
合計ジャッジ時間 | 13,571 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
#region Header #!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools from queue import PriorityQueue import bisect import heapq def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) #endregion # _INPUT = """10 # EEEEEEEEEE # 1 2 3 4 5 6 7 8 9 10 # 10 # 1 2 3 4 5 6 7 8 9 10 # """ # sys.stdin = io.StringIO(_INPUT) def main(): N = int(input()) S = input() A = list(map(int, input().split())) Q = int(input()) K = list(map(int, input().split())) # T[i] := A[0]~A[i-1] を倒すのに必要な威力(累積和) T = [0] # C[i] := A[0]~A[i-1] の間の敵の数 C = [0] for i in range(N): T.append(T[-1] + A[i]) if S[i] == 'E': C.append(C[-1] + 1) else: C.append(C[-1]) for power in K: score = 0 r = 0 for l in range(N): while r < N and T[r+1] - T[l] <= power: r += 1 score1 = C[r] - C[l] score = max(score, score1) if r == l: r += 1 print(score) if __name__ == '__main__': main()