結果

問題 No.2694 The Early Bird Catches The Worm
コンテスト
ユーザー miya145592
提出日時 2024-03-22 22:38:53
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 555 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 283 ms
コンパイル使用メモリ 84,936 KB
実行使用メモリ 161,320 KB
最終ジャッジ日時 2026-04-16 15:45:00
合計ジャッジ時間 14,019 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
N, H = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
SA = [0]
for a in A:
    SA.append(SA[-1]+a)
SB = [0]
for b in B:
    SB.append(SB[-1]+b)
SH = [0]
for i, b in enumerate(B):
    SH.append(SH[-1]+(i+1)*b)
ans = 0
for i in range(N):
    l = i-1
    r = N
    while r-l>1:
        mid = (l+r)//2
        tmp = SH[mid+1]-SH[i]-(SB[mid+1]-SB[i])*i
        if tmp<=H:
            l = mid
        else:
            r = mid
    ans = max(ans, SA[l+1]-SA[i])
print(ans)
0