結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー KudeKude
提出日時 2024-03-22 21:34:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 131,792 KB
最終ジャッジ日時 2024-09-30 10:59:48
合計ジャッジ時間 10,376 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

n, h = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = asm = bsm = now = ans = 0
for l in range(n):
    while r < n and now + (r + 1 - l) * b[r] <= h:
        asm += a[r]
        bsm += b[r]
        now += (r + 1 - l) * b[r]
        r += 1
    ans = max(ans, asm)
    if r == l:
        r += 1
    else:
        now -= bsm
        asm -= a[l]
        bsm -= b[l]
print(ans)
0