結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー FromBooskaFromBooska
提出日時 2024-03-23 16:05:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 1,172 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 161,696 KB
最終ジャッジ日時 2024-03-23 16:05:29
合計ジャッジ時間 12,062 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 40 ms
59,444 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 38 ms
59,444 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 35 ms
53,460 KB
testcase_12 AC 36 ms
53,460 KB
testcase_13 AC 35 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 36 ms
53,460 KB
testcase_16 AC 37 ms
53,460 KB
testcase_17 AC 38 ms
53,460 KB
testcase_18 AC 36 ms
53,460 KB
testcase_19 AC 35 ms
53,460 KB
testcase_20 AC 36 ms
53,460 KB
testcase_21 AC 36 ms
53,460 KB
testcase_22 AC 35 ms
53,460 KB
testcase_23 AC 36 ms
53,460 KB
testcase_24 AC 108 ms
95,980 KB
testcase_25 AC 81 ms
93,176 KB
testcase_26 AC 106 ms
96,312 KB
testcase_27 AC 130 ms
99,324 KB
testcase_28 AC 108 ms
102,052 KB
testcase_29 AC 59 ms
81,308 KB
testcase_30 AC 147 ms
124,948 KB
testcase_31 AC 108 ms
99,440 KB
testcase_32 AC 197 ms
125,476 KB
testcase_33 AC 170 ms
125,448 KB
testcase_34 AC 55 ms
70,512 KB
testcase_35 AC 98 ms
98,628 KB
testcase_36 AC 145 ms
108,188 KB
testcase_37 AC 182 ms
132,576 KB
testcase_38 AC 123 ms
111,176 KB
testcase_39 AC 58 ms
79,264 KB
testcase_40 AC 104 ms
99,404 KB
testcase_41 AC 78 ms
88,316 KB
testcase_42 AC 44 ms
64,308 KB
testcase_43 AC 56 ms
73,292 KB
testcase_44 AC 153 ms
131,808 KB
testcase_45 AC 137 ms
131,680 KB
testcase_46 AC 94 ms
95,920 KB
testcase_47 AC 78 ms
96,340 KB
testcase_48 AC 115 ms
102,052 KB
testcase_49 AC 151 ms
131,116 KB
testcase_50 AC 153 ms
130,980 KB
testcase_51 AC 150 ms
131,784 KB
testcase_52 AC 152 ms
131,116 KB
testcase_53 AC 150 ms
131,544 KB
testcase_54 AC 198 ms
161,564 KB
testcase_55 AC 204 ms
161,692 KB
testcase_56 AC 187 ms
161,564 KB
testcase_57 AC 235 ms
161,568 KB
testcase_58 AC 166 ms
161,572 KB
testcase_59 AC 218 ms
161,568 KB
testcase_60 AC 217 ms
161,696 KB
testcase_61 AC 169 ms
161,440 KB
testcase_62 AC 227 ms
161,568 KB
testcase_63 AC 210 ms
161,568 KB
testcase_64 AC 168 ms
161,568 KB
testcase_65 AC 175 ms
161,656 KB
testcase_66 AC 198 ms
161,564 KB
testcase_67 AC 171 ms
161,564 KB
testcase_68 AC 164 ms
161,568 KB
testcase_69 AC 152 ms
156,964 KB
testcase_70 AC 153 ms
156,964 KB
testcase_71 AC 152 ms
156,956 KB
testcase_72 AC 154 ms
156,956 KB
testcase_73 AC 156 ms
156,964 KB
testcase_74 AC 94 ms
104,432 KB
testcase_75 AC 155 ms
156,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 後ろから累積和してみたが高速計算できない
# しゃくとり法だった, ABC032C利用

N, H = map(int, input().split())
A = [0]+list(map(int, input().split()))
B = [0]+list(map(int, input().split()))

A_cumu = []
temp = 0
for a in A:
    temp += a
    A_cumu.append(temp)

B_cumu = []
temp = 0
for b in B:
    temp += b
    B_cumu.append(temp)

#print('A', A)
#print('A_cumu', A_cumu)
#print('B', B)
#print('B_cumu', B_cumu)

right = 1
left = 1
ans = 0
calc = 0
while left < N+1 and right < N+1:
    while right < N+1:
        #print('right', right, '(right+1-left)', (right+1-left))
        if calc+B[right]*(right+1-left) <= H:
            calc += B[right]*(right+1-left)
            ans = max(ans, A_cumu[right]-A_cumu[left-1])
            #print('(right+1-left)', (right+1-left), 'calc', calc, 'ans', ans)
            right += 1
        else:
            break
    #print('前', 'left', left, 'right', right, 'calc', calc, 'ans', ans)
    
    calc -= (B_cumu[right-1]-B_cumu[left-1])
    left += 1
    if left >= right:
        right = left 
        calc = 0

    #print('後', 'left', left, 'right', right, 'calc', calc, 'ans', ans)

print(ans)
0