結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー FromBooska
提出日時 2023-03-18 20:46:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,146 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-09-18 13:34:29
合計ジャッジ時間 16,675 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

# 累積和、enemy count 
# 任意の場所から打てるときの最大値
# つまりある区間の和がk以下のときのEの数

N = int(input())
S = input()
enemy_count = [0]*(N+1)
for i in range(N):
    if i == 0:
        if S[i] == 'E':
            enemy_count[i+1] = 1
        else:
            enemy_count[i+1] = 0
    else:
        if S[i] == 'E':
            enemy_count[i+1] = enemy_count[i]+1
        else:
            enemy_count[i+1] = enemy_count[i]       
HP = list(map(int, input().split()))
HP_cumu = [0]
temp = 0
for i in range(N):
    temp += HP[i]
    HP_cumu.append(temp)
    
from bisect import *
Q = int(input())
K = list(map(int, input().split()))
for k in K:
    if k == 0:
        print(0)
        continue
    
    ans = 0
    for i in range(N):
        base = HP_cumu[i]
        idx = bisect_left(HP_cumu, base+k)
        #print('k', k, 'idx', idx)
        if idx > N:
            ans = max(ans, enemy_count[N]-enemy_count[i])
        elif HP_cumu[idx] == k:
            ans = max(ans, enemy_count[idx]-enemy_count[i])
        else:
            ans = max(ans, enemy_count[idx-1]-enemy_count[i])
    print(ans)

0