結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー 👑 rin204
提出日時 2024-03-22 21:32:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 82,056 KB
実行使用メモリ 145,752 KB
最終ジャッジ日時 2024-09-30 10:57:35
合計ジャッジ時間 10,382 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()))
cum = [0]
for b in B:
    cum.append(cum[-1] + b)

ans = 0
r = 0
tot = 0
ca = 0
for l in range(n):
    while r < n:
        ntot = tot + B[r] * (r - l + 1)
        if ntot > h:
            break
        tot = ntot
        ca += A[r]
        r += 1
    ans = max(ans, ca)
    ca -= A[l]
    tot -= cum[r] - cum[l]

print(ans)
0