結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー 👑 timitimi
提出日時 2024-03-02 19:10:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 168,160 KB
最終ジャッジ日時 2024-03-02 19:10:25
合計ジャッジ時間 13,584 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,724 KB
testcase_01 AC 39 ms
55,724 KB
testcase_02 AC 38 ms
55,724 KB
testcase_03 AC 39 ms
55,724 KB
testcase_04 AC 39 ms
55,724 KB
testcase_05 AC 39 ms
55,724 KB
testcase_06 AC 48 ms
64,312 KB
testcase_07 AC 45 ms
61,800 KB
testcase_08 AC 44 ms
61,724 KB
testcase_09 AC 50 ms
61,664 KB
testcase_10 AC 46 ms
61,664 KB
testcase_11 AC 46 ms
61,664 KB
testcase_12 AC 45 ms
61,672 KB
testcase_13 AC 40 ms
55,724 KB
testcase_14 AC 45 ms
61,664 KB
testcase_15 AC 41 ms
55,724 KB
testcase_16 AC 41 ms
55,724 KB
testcase_17 AC 45 ms
61,664 KB
testcase_18 AC 49 ms
63,928 KB
testcase_19 AC 40 ms
55,724 KB
testcase_20 AC 44 ms
61,664 KB
testcase_21 AC 40 ms
55,724 KB
testcase_22 AC 40 ms
55,724 KB
testcase_23 AC 48 ms
63,928 KB
testcase_24 AC 110 ms
91,736 KB
testcase_25 AC 84 ms
89,360 KB
testcase_26 AC 102 ms
91,048 KB
testcase_27 AC 120 ms
104,088 KB
testcase_28 AC 120 ms
109,288 KB
testcase_29 AC 97 ms
84,880 KB
testcase_30 AC 174 ms
133,692 KB
testcase_31 AC 113 ms
104,400 KB
testcase_32 AC 167 ms
133,932 KB
testcase_33 AC 163 ms
134,300 KB
testcase_34 AC 62 ms
72,880 KB
testcase_35 AC 105 ms
100,348 KB
testcase_36 AC 127 ms
111,300 KB
testcase_37 AC 186 ms
160,104 KB
testcase_38 AC 128 ms
117,024 KB
testcase_39 AC 70 ms
83,008 KB
testcase_40 AC 108 ms
104,364 KB
testcase_41 AC 82 ms
86,128 KB
testcase_42 AC 52 ms
66,664 KB
testcase_43 AC 62 ms
74,184 KB
testcase_44 AC 173 ms
160,256 KB
testcase_45 AC 162 ms
160,256 KB
testcase_46 AC 97 ms
91,444 KB
testcase_47 AC 84 ms
91,820 KB
testcase_48 AC 123 ms
109,288 KB
testcase_49 AC 193 ms
146,428 KB
testcase_50 AC 224 ms
146,560 KB
testcase_51 AC 202 ms
146,432 KB
testcase_52 AC 225 ms
146,556 KB
testcase_53 AC 196 ms
146,596 KB
testcase_54 AC 196 ms
144,212 KB
testcase_55 AC 204 ms
144,224 KB
testcase_56 AC 189 ms
144,224 KB
testcase_57 AC 215 ms
144,224 KB
testcase_58 AC 180 ms
144,224 KB
testcase_59 AC 203 ms
144,224 KB
testcase_60 AC 200 ms
144,228 KB
testcase_61 AC 205 ms
144,224 KB
testcase_62 AC 206 ms
144,224 KB
testcase_63 AC 213 ms
144,216 KB
testcase_64 AC 173 ms
144,220 KB
testcase_65 AC 198 ms
144,220 KB
testcase_66 AC 192 ms
144,224 KB
testcase_67 AC 178 ms
144,224 KB
testcase_68 AC 174 ms
144,216 KB
testcase_69 AC 232 ms
168,144 KB
testcase_70 AC 209 ms
168,156 KB
testcase_71 AC 211 ms
168,160 KB
testcase_72 AC 210 ms
168,156 KB
testcase_73 AC 211 ms
168,156 KB
testcase_74 AC 127 ms
105,820 KB
testcase_75 AC 224 ms
168,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque  
mod=998244353
from sys import stdin, setrecursionlimit
input = stdin.readline
readline = stdin.readline
import math
N,H=map(int, stdin.readline().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
B.append(10**10)
AA=[0]
for a in A:
  AA.append(AA[-1]+a)
BB=[0];C=[0]
for i in range(N+1):
  BB.append(BB[-1]+(i+1)*B[i])
  C.append(C[-1]+B[i])
# print(AA)
# print(BB)
# print(C)

if min(B)>H:
  print(0)
  exit()
  
ans=0
for i in range(N):
  l,r=i,N+1
  if B[i]>H:
    continue
  while abs(l-r)>1:
    mid=(l+r)//2
    c=BB[mid]-BB[i]
    cc=C[mid]-C[i] 
    d=c-cc*i
    if d<=H:
      l=mid 
    else:
      r=mid 
  e=AA[l]-AA[i]
  ans=max(ans,e)
print(ans)
0