結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー navel_tosnavel_tos
提出日時 2024-03-22 23:13:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 134,548 KB
最終ジャッジ日時 2024-03-22 23:13:57
合計ジャッジ時間 10,882 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 42 ms
59,444 KB
testcase_07 AC 38 ms
53,460 KB
testcase_08 AC 42 ms
59,444 KB
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 38 ms
53,460 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 37 ms
53,460 KB
testcase_14 AC 39 ms
53,460 KB
testcase_15 AC 38 ms
53,460 KB
testcase_16 AC 38 ms
53,460 KB
testcase_17 AC 38 ms
53,460 KB
testcase_18 AC 42 ms
53,460 KB
testcase_19 AC 38 ms
53,460 KB
testcase_20 AC 39 ms
53,460 KB
testcase_21 AC 37 ms
53,460 KB
testcase_22 AC 38 ms
53,460 KB
testcase_23 AC 38 ms
53,460 KB
testcase_24 AC 83 ms
90,348 KB
testcase_25 AC 80 ms
88,188 KB
testcase_26 AC 89 ms
93,016 KB
testcase_27 AC 116 ms
98,656 KB
testcase_28 AC 103 ms
97,988 KB
testcase_29 AC 63 ms
78,808 KB
testcase_30 AC 130 ms
105,240 KB
testcase_31 AC 104 ms
98,760 KB
testcase_32 AC 139 ms
105,640 KB
testcase_33 AC 131 ms
105,736 KB
testcase_34 AC 57 ms
68,440 KB
testcase_35 AC 98 ms
98,648 KB
testcase_36 AC 109 ms
98,664 KB
testcase_37 AC 144 ms
110,180 KB
testcase_38 AC 113 ms
97,752 KB
testcase_39 AC 63 ms
77,568 KB
testcase_40 AC 100 ms
98,724 KB
testcase_41 AC 85 ms
85,064 KB
testcase_42 AC 50 ms
62,204 KB
testcase_43 AC 61 ms
72,552 KB
testcase_44 AC 137 ms
109,408 KB
testcase_45 AC 130 ms
109,280 KB
testcase_46 AC 85 ms
90,416 KB
testcase_47 AC 82 ms
90,784 KB
testcase_48 AC 99 ms
97,992 KB
testcase_49 AC 141 ms
113,436 KB
testcase_50 AC 138 ms
113,564 KB
testcase_51 AC 150 ms
113,564 KB
testcase_52 AC 136 ms
113,564 KB
testcase_53 AC 137 ms
113,584 KB
testcase_54 AC 172 ms
134,544 KB
testcase_55 AC 163 ms
134,544 KB
testcase_56 AC 160 ms
134,544 KB
testcase_57 AC 158 ms
134,416 KB
testcase_58 AC 163 ms
134,548 KB
testcase_59 AC 157 ms
134,288 KB
testcase_60 AC 167 ms
134,544 KB
testcase_61 AC 152 ms
134,292 KB
testcase_62 AC 160 ms
134,544 KB
testcase_63 AC 164 ms
134,416 KB
testcase_64 AC 155 ms
134,288 KB
testcase_65 AC 182 ms
134,432 KB
testcase_66 AC 161 ms
134,416 KB
testcase_67 AC 156 ms
134,540 KB
testcase_68 AC 186 ms
134,416 KB
testcase_69 AC 142 ms
129,812 KB
testcase_70 AC 140 ms
129,812 KB
testcase_71 AC 140 ms
129,808 KB
testcase_72 AC 145 ms
129,804 KB
testcase_73 AC 141 ms
129,812 KB
testcase_74 AC 95 ms
104,288 KB
testcase_75 AC 140 ms
129,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder423D The Early Bird Catches The Worm

N, H = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0

#累積和を取っておく  なんかに使うと思う
C = [0] * (N + 1)
D = [0] * (N + 1)
for i in range(N):
    C[i + 1] = A[i] + C[i]
    D[i + 1] = B[i] + D[i]
Rt = sat = hel = 0
for Lt in range(N):
    #1. 区間Lt - 1を捨てる
    if Lt:
        sat -= A[Lt - 1]
        #[Lt - 1: Rt)の疲労度が1日分回復
        hel -= D[Rt] - D[Lt - 1]

    if Lt > Rt:
        sat = hel = 0
        Rt = Lt

    #2. 疲れが限界を迎えるまで伸ばす
    while True:
        if Rt == N:
            break
        #Rtを追加したときの疲労度変化をシミュレート
        nxt = hel + B[Rt] * (Rt + 1 - Lt)
        if nxt <= H:
            hel = nxt
            sat += A[Rt]
            Rt += 1
        else: break
    ans = max(ans, sat)
print(ans)
0