結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー sasa8uyauya
提出日時 2024-03-23 04:18:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 272 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 131,832 KB
最終ジャッジ日時 2024-09-30 13:02:50
合計ジャッジ時間 10,379 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()))
g=0
r=0
s1=0
s2=0
s3=0
for l in range(n):
	while r+1<=n and s2+(r+1-l)*b[r]<=h:
		s1+=a[r]
		s2+=(r+1-l)*b[r]
		s3+=b[r]
		r+=1
	g=max(g,s1)
	s1-=a[l]
	s2-=s3
	s3-=b[l]
print(g)
0