結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー mo124121mo124121
提出日時 2024-02-15 23:39:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 147,428 KB
最終ジャッジ日時 2024-09-28 23:32:36
合計ジャッジ時間 11,428 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque


N, H = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

q = deque()
ans = 0

fatigue = 0
cum = 0
score = 0
for a, b in reversed(list(zip(A, B))):
    score += a
    cum += b
    fatigue += cum
    q.appendleft((a, b))
    while fatigue > H:
        aprev, bprev = q.pop()
        score -= aprev
        cum -= bprev
        fatigue -= bprev * (len(q) + 1)
    ans = max(ans, score)
print(ans)
0