結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー hato336hato336
提出日時 2024-03-22 21:38:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 144,696 KB
最終ジャッジ日時 2024-03-22 21:39:09
合計ジャッジ時間 17,553 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
85,048 KB
testcase_01 AC 133 ms
85,048 KB
testcase_02 AC 126 ms
85,048 KB
testcase_03 AC 125 ms
85,048 KB
testcase_04 AC 124 ms
85,048 KB
testcase_05 AC 123 ms
85,048 KB
testcase_06 AC 136 ms
88,760 KB
testcase_07 AC 132 ms
85,048 KB
testcase_08 AC 138 ms
88,760 KB
testcase_09 AC 137 ms
88,248 KB
testcase_10 AC 133 ms
85,048 KB
testcase_11 AC 124 ms
85,048 KB
testcase_12 AC 126 ms
85,048 KB
testcase_13 AC 124 ms
85,048 KB
testcase_14 AC 126 ms
85,048 KB
testcase_15 AC 127 ms
85,048 KB
testcase_16 AC 126 ms
85,048 KB
testcase_17 AC 129 ms
85,048 KB
testcase_18 AC 146 ms
88,248 KB
testcase_19 AC 127 ms
85,048 KB
testcase_20 AC 125 ms
85,048 KB
testcase_21 AC 127 ms
85,048 KB
testcase_22 AC 131 ms
85,048 KB
testcase_23 AC 136 ms
88,248 KB
testcase_24 AC 182 ms
102,072 KB
testcase_25 AC 172 ms
100,152 KB
testcase_26 AC 183 ms
104,504 KB
testcase_27 AC 190 ms
112,952 KB
testcase_28 AC 190 ms
116,536 KB
testcase_29 AC 151 ms
94,008 KB
testcase_30 AC 223 ms
124,472 KB
testcase_31 AC 186 ms
112,952 KB
testcase_32 AC 239 ms
122,552 KB
testcase_33 AC 218 ms
123,704 KB
testcase_34 AC 150 ms
89,400 KB
testcase_35 AC 182 ms
109,880 KB
testcase_36 AC 196 ms
120,376 KB
testcase_37 AC 225 ms
121,528 KB
testcase_38 AC 211 ms
124,856 KB
testcase_39 AC 151 ms
92,984 KB
testcase_40 AC 186 ms
113,080 KB
testcase_41 AC 166 ms
96,824 KB
testcase_42 AC 143 ms
89,144 KB
testcase_43 AC 150 ms
89,400 KB
testcase_44 AC 217 ms
121,272 KB
testcase_45 AC 232 ms
121,272 KB
testcase_46 AC 172 ms
102,072 KB
testcase_47 AC 161 ms
101,944 KB
testcase_48 AC 184 ms
116,536 KB
testcase_49 AC 224 ms
144,568 KB
testcase_50 AC 222 ms
144,568 KB
testcase_51 AC 234 ms
144,568 KB
testcase_52 AC 224 ms
144,568 KB
testcase_53 AC 224 ms
144,696 KB
testcase_54 AC 233 ms
122,552 KB
testcase_55 AC 233 ms
122,552 KB
testcase_56 AC 239 ms
122,552 KB
testcase_57 AC 231 ms
122,552 KB
testcase_58 AC 228 ms
122,552 KB
testcase_59 AC 239 ms
122,552 KB
testcase_60 AC 235 ms
122,552 KB
testcase_61 AC 234 ms
122,552 KB
testcase_62 AC 235 ms
122,552 KB
testcase_63 AC 231 ms
122,552 KB
testcase_64 AC 229 ms
122,552 KB
testcase_65 AC 231 ms
122,552 KB
testcase_66 AC 230 ms
122,552 KB
testcase_67 AC 233 ms
122,552 KB
testcase_68 AC 226 ms
122,552 KB
testcase_69 AC 217 ms
132,792 KB
testcase_70 AC 216 ms
132,792 KB
testcase_71 AC 220 ms
132,792 KB
testcase_72 AC 219 ms
132,792 KB
testcase_73 AC 228 ms
132,792 KB
testcase_74 AC 186 ms
115,256 KB
testcase_75 AC 215 ms
132,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
input = sys.stdin.readline
#n = int(input())
#alist = list(map(int,input().split()))
#alist = []
#s = input()
n,h = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
#https://github.com/tsutaj/pastbook-2-source-code/blob/main/python/chapter3/3-2-1.py
l, r = 0, 0
fat = 0
temp = 0
res = 0
for l in range(n):
    while r < n and fat + b[r] * (r-l+1) <= h:
        fat += b[r] * (r-l+1)
        temp += b[r]
        res += a[r]
        r += 1
    ans = max(ans, res)
    if r - l >= 1:
        fat -= temp
        temp -= b[l]
        res -= a[l]
    else:
        r += 1
print(ans)
0