結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー とりゐ
提出日時 2024-03-22 21:35:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 82,020 KB
実行使用メモリ 131,844 KB
最終ジャッジ日時 2024-09-30 11:02:09
合計ジャッジ時間 10,889 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()))
ans=0
R=0
cumA=0
cumB=0
resB=0
for L in range(N):
  while R!=N:
    ncumA=cumA+A[R]
    ncumB=cumB+B[R]*(R-L+1)
    nresB=resB+B[R]
    if ncumB<=H:
      R+=1
      cumA=ncumA
      cumB=ncumB
      resB=nresB
    else:
      break
  ans=max(ans,cumA)
  cumA-=A[L]
  cumB-=resB
  resB-=B[L]
print(ans)
0