結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー june19312june19312
提出日時 2024-03-22 22:51:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 1,025 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 148,928 KB
最終ジャッジ日時 2024-03-22 22:51:25
合計ジャッジ時間 13,896 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,596 KB
testcase_01 AC 39 ms
55,596 KB
testcase_02 AC 40 ms
55,596 KB
testcase_03 AC 47 ms
55,596 KB
testcase_04 AC 40 ms
55,596 KB
testcase_05 AC 40 ms
55,596 KB
testcase_06 AC 46 ms
61,576 KB
testcase_07 AC 41 ms
55,596 KB
testcase_08 AC 49 ms
61,576 KB
testcase_09 AC 42 ms
55,596 KB
testcase_10 AC 41 ms
55,596 KB
testcase_11 AC 43 ms
55,596 KB
testcase_12 AC 41 ms
55,596 KB
testcase_13 AC 41 ms
55,596 KB
testcase_14 AC 42 ms
55,596 KB
testcase_15 AC 42 ms
55,596 KB
testcase_16 AC 43 ms
55,596 KB
testcase_17 AC 42 ms
55,596 KB
testcase_18 AC 42 ms
55,596 KB
testcase_19 AC 41 ms
55,596 KB
testcase_20 AC 43 ms
55,596 KB
testcase_21 AC 41 ms
55,596 KB
testcase_22 AC 41 ms
55,596 KB
testcase_23 AC 42 ms
55,596 KB
testcase_24 AC 127 ms
93,232 KB
testcase_25 AC 96 ms
91,148 KB
testcase_26 AC 112 ms
92,256 KB
testcase_27 AC 137 ms
97,184 KB
testcase_28 AC 129 ms
102,244 KB
testcase_29 AC 74 ms
83,920 KB
testcase_30 AC 162 ms
118,752 KB
testcase_31 AC 120 ms
96,600 KB
testcase_32 AC 198 ms
119,572 KB
testcase_33 AC 177 ms
119,372 KB
testcase_34 AC 74 ms
76,568 KB
testcase_35 AC 115 ms
95,080 KB
testcase_36 AC 155 ms
106,632 KB
testcase_37 AC 195 ms
143,284 KB
testcase_38 AC 136 ms
107,532 KB
testcase_39 AC 75 ms
82,556 KB
testcase_40 AC 118 ms
94,896 KB
testcase_41 AC 115 ms
87,760 KB
testcase_42 AC 51 ms
66,644 KB
testcase_43 AC 75 ms
76,856 KB
testcase_44 AC 180 ms
143,344 KB
testcase_45 AC 158 ms
143,084 KB
testcase_46 AC 107 ms
93,332 KB
testcase_47 AC 86 ms
92,880 KB
testcase_48 AC 126 ms
101,608 KB
testcase_49 AC 248 ms
131,284 KB
testcase_50 AC 195 ms
130,768 KB
testcase_51 AC 213 ms
131,284 KB
testcase_52 AC 213 ms
130,740 KB
testcase_53 AC 200 ms
131,200 KB
testcase_54 AC 206 ms
148,928 KB
testcase_55 AC 223 ms
148,920 KB
testcase_56 AC 203 ms
148,928 KB
testcase_57 AC 209 ms
148,928 KB
testcase_58 AC 185 ms
148,928 KB
testcase_59 AC 202 ms
148,924 KB
testcase_60 AC 210 ms
148,928 KB
testcase_61 AC 222 ms
148,792 KB
testcase_62 AC 210 ms
148,920 KB
testcase_63 AC 208 ms
148,924 KB
testcase_64 AC 180 ms
148,800 KB
testcase_65 AC 205 ms
148,924 KB
testcase_66 AC 230 ms
148,928 KB
testcase_67 AC 188 ms
148,928 KB
testcase_68 AC 180 ms
148,796 KB
testcase_69 AC 192 ms
147,392 KB
testcase_70 AC 190 ms
147,388 KB
testcase_71 AC 191 ms
147,388 KB
testcase_72 AC 216 ms
147,392 KB
testcase_73 AC 193 ms
147,388 KB
testcase_74 AC 129 ms
99,596 KB
testcase_75 AC 189 ms
147,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N,H = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

rui = []
for i,v in enumerate(B):
    if i == 0:
        rui.append(v)
    else:
        rui.append(rui[-1]+v)

#print("rui")
#print(rui)
#print("B")
#print(B)
#print("A")
#print(A)
#print()

Q1,Q2 = deque(list(range(N))),deque()

tired = 0
manzoku = 0
ans = 0

for i,v in enumerate(B):
    while Q1:
        if (len(Q2)+1)*B[Q1[0]] + tired <= H:
            tired += (len(Q2)+1)*B[Q1[0]]
            manzoku += A[Q1[0]]
            Q2.append(Q1.popleft())
        else:
            break

    ans = max(ans,manzoku)

#    print("before","Q2",Q2,"tired",tired,"manzoku",manzoku)

    if len(Q2):
        nex1 = Q2[0]
        nex2 = Q2[-1]
        tired -= rui[nex2]
        if nex1 != 0:
            tired += rui[nex1-1]
        manzoku -= A[nex1]
        Q2.popleft()
    else:
        Q1.popleft()

#    print("after","Q2",Q2,"tired",tired,"manzoku",manzoku)
#    print()
print(ans)
        
0