結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー flippergo
提出日時 2025-07-15 20:07:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 138,188 KB
最終ジャッジ日時 2025-07-15 20:07:20
合計ジャッジ時間 12,322 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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]*(N+1)
cumB = [0]*(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
hirou = 0
r = 0
for l in range(1,N+1):
    while hirou<=H:
        r += 1
        if r>N:break
        hirou += (r-l+1)*B[r]
    if r>N:
        r -= 1
    if hirou>H:
        hirou -= (r-l+1)*B[r]
        r -= 1
    ans = max(ans,cumA[r]-cumA[l-1])
    hirou -= (cumB[r]-cumB[l-1])
print(ans)
0