結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー tkykwtnb
提出日時 2024-03-23 08:25:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 554 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 48,888 KB
最終ジャッジ日時 2024-09-30 13:07:41
合計ジャッジ時間 23,372 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

N,H=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))
cumA=[0 for _ in range(N+1)]
cumB=[0 for _ in range(N+1)]
for i in range(1,N+1):
    cumA[i]=cumA[i-1]+A[i]
    cumB[i]=cumB[i-1]+B[i]
ans=0
l=1
s=0
for r in range(1,N+1):
    s+=(r-l+1)*B[r]
    while s>H:
        s-=cumB[r]-cumB[l-1]
        l+=1
    ans=max(ans,cumA[r]-cumA[l-1])
print(ans)
0