結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー mymelochan
提出日時 2024-03-22 21:42:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 170,128 KB
最終ジャッジ日時 2024-09-30 11:10:19
合計ジャッジ時間 12,393 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations

ipt = sys.stdin.readline

def iin():
    return int(ipt())
def lmin():
    return list(map(int,ipt().split()))

MOD = 998244353
#############################################################

N,H = lmin()
A = lmin()
B = lmin()

SA = [0]
for a in A:
    SA.append(SA[-1]+a)
SB = [0]
SSB = [0]
for i,b in enumerate(B):
    SB.append(SB[-1]+b*(i+1))
    SSB.append(SSB[-1]+b)

ans = 0
for i in range(N):
    ok = i
    ng = N+1
    while ng-ok > 1:
        cen = (ok+ng)//2
        if SB[cen]-SB[i]-(SSB[cen]-SSB[i])*i <= H:
            ok = cen
        else:
            ng = cen
    ans = max(ans,SA[ok]-SA[i])
print(ans)
0