結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー flippergo
提出日時 2025-07-15 15:44:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 138,340 KB
最終ジャッジ日時 2025-07-15 15:44:20
合計ジャッジ時間 13,016 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 51
権限があれば一括ダウンロードができます

ソースコード

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):
    hirou -= (r-l+2)*B[l-1]
    while hirou<=H:
        r += 1
        if r>N:break
        hirou += cumB[r]-cumB[l-1]
    if r>N:
        r -= 1
    if hirou>H:
        hirou -= cumB[r]-cumB[l-1]
        r -= 1
    ans = max(ans,cumA[r]-cumA[l-1])
print(ans)
0