結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー ypww
提出日時 2024-02-15 22:26:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 569 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 48,884 KB
最終ジャッジ日時 2024-09-28 22:32:44
合計ジャッジ時間 23,996 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()))

suma = [0]
for i in range(n):
    suma.append(suma[-1]+a[i])

sumb = [0]
for i in range(n):
    sumb.append(sumb[-1]+b[i])

now = 0
r = 0
ans = 0
for l in range(n):
    if l!=0:
        now -= sumb[r] - sumb[l-1]
    while r<n and now + (r-l+1)*b[r] <= h:
        now += (r-l+1) * b[r]
        r += 1
    ans = max(ans, suma[r] - suma[l])
print(ans)
0