結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー ThetaTheta
提出日時 2024-04-24 13:31:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 154,344 KB
最終ジャッジ日時 2024-04-24 13:32:14
合計ジャッジ時間 12,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,712 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 36 ms
52,224 KB
testcase_03 AC 39 ms
52,224 KB
testcase_04 AC 41 ms
52,352 KB
testcase_05 AC 40 ms
51,712 KB
testcase_06 AC 48 ms
59,648 KB
testcase_07 AC 42 ms
52,352 KB
testcase_08 AC 46 ms
58,880 KB
testcase_09 AC 44 ms
52,480 KB
testcase_10 AC 41 ms
52,480 KB
testcase_11 AC 40 ms
52,096 KB
testcase_12 AC 39 ms
52,096 KB
testcase_13 AC 37 ms
52,352 KB
testcase_14 AC 43 ms
52,224 KB
testcase_15 AC 38 ms
52,480 KB
testcase_16 AC 38 ms
52,864 KB
testcase_17 AC 37 ms
52,608 KB
testcase_18 AC 38 ms
52,992 KB
testcase_19 AC 38 ms
52,480 KB
testcase_20 AC 43 ms
52,480 KB
testcase_21 AC 39 ms
52,096 KB
testcase_22 AC 39 ms
51,968 KB
testcase_23 AC 40 ms
52,480 KB
testcase_24 AC 86 ms
93,312 KB
testcase_25 AC 83 ms
92,288 KB
testcase_26 AC 89 ms
95,232 KB
testcase_27 AC 104 ms
98,944 KB
testcase_28 AC 107 ms
101,128 KB
testcase_29 AC 69 ms
81,556 KB
testcase_30 AC 139 ms
123,872 KB
testcase_31 AC 101 ms
98,688 KB
testcase_32 AC 136 ms
124,356 KB
testcase_33 AC 146 ms
124,500 KB
testcase_34 AC 56 ms
67,072 KB
testcase_35 AC 93 ms
97,408 KB
testcase_36 AC 112 ms
105,036 KB
testcase_37 AC 149 ms
131,324 KB
testcase_38 AC 121 ms
110,712 KB
testcase_39 AC 65 ms
78,976 KB
testcase_40 AC 101 ms
98,560 KB
testcase_41 AC 75 ms
87,808 KB
testcase_42 AC 48 ms
61,824 KB
testcase_43 AC 65 ms
70,784 KB
testcase_44 AC 162 ms
130,084 KB
testcase_45 AC 144 ms
130,348 KB
testcase_46 AC 94 ms
94,336 KB
testcase_47 AC 84 ms
92,800 KB
testcase_48 AC 106 ms
101,080 KB
testcase_49 AC 142 ms
130,360 KB
testcase_50 AC 150 ms
130,100 KB
testcase_51 AC 147 ms
130,148 KB
testcase_52 AC 146 ms
130,600 KB
testcase_53 AC 159 ms
130,140 KB
testcase_54 AC 169 ms
146,020 KB
testcase_55 AC 163 ms
145,900 KB
testcase_56 AC 167 ms
145,900 KB
testcase_57 AC 178 ms
145,884 KB
testcase_58 AC 169 ms
146,148 KB
testcase_59 AC 177 ms
145,800 KB
testcase_60 AC 168 ms
145,644 KB
testcase_61 AC 168 ms
145,888 KB
testcase_62 AC 165 ms
145,892 KB
testcase_63 AC 170 ms
146,080 KB
testcase_64 AC 164 ms
145,388 KB
testcase_65 AC 172 ms
145,636 KB
testcase_66 AC 179 ms
145,516 KB
testcase_67 AC 168 ms
145,892 KB
testcase_68 AC 167 ms
145,900 KB
testcase_69 AC 161 ms
153,836 KB
testcase_70 AC 161 ms
154,212 KB
testcase_71 AC 164 ms
153,820 KB
testcase_72 AC 163 ms
154,344 KB
testcase_73 AC 170 ms
153,704 KB
testcase_74 AC 97 ms
102,272 KB
testcase_75 AC 160 ms
153,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
import sys


def printe(*args, end="\n", **kwargs):
    print(*args, end=end, file=sys.stderr, **kwargs)


def main():
    N, H = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A_accum = list(accumulate(A))
    B_accum = list(accumulate(B, initial=0))

    max_satisfied = 0
    L = 0
    R = 0
    cur_tired = 0
    cur_satisfied = 0
    while L < N:

        if R == N:
            max_satisfied = max(max_satisfied, cur_satisfied)
            break
        if cur_tired + B[R] * (R - L + 1) <= H:
            cur_tired += B[R] * (R - L + 1)
            cur_satisfied += A[R]
            R += 1
            continue

        max_satisfied = max(max_satisfied, cur_satisfied)
        if L < R:
            cur_satisfied -= A[L]
            cur_tired -= B_accum[R] - B_accum[L]
            L += 1
        else:
            L += 1
            R += 1
        # cur_satisfied += A[R]

        # cur_tired += B[R] * (R - L)
        # R += 1
        # L += 1
    print(max_satisfied)


if __name__ == "__main__":
    main()
0