結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー mo124121
提出日時 2024-02-16 01:02:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 43,112 KB
最終ジャッジ日時 2024-09-28 23:33:00
合計ジャッジ時間 22,733 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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