結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー H3PO4H3PO4
提出日時 2021-07-20 12:56:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 377 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 55,764 KB
最終ジャッジ日時 2023-09-24 12:47:07
合計ジャッジ時間 16,981 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 377 ms
29,712 KB
testcase_01 AC 141 ms
29,824 KB
testcase_02 AC 139 ms
29,852 KB
testcase_03 AC 138 ms
29,800 KB
testcase_04 AC 138 ms
29,724 KB
testcase_05 AC 138 ms
29,856 KB
testcase_06 AC 137 ms
29,764 KB
testcase_07 AC 137 ms
29,784 KB
testcase_08 AC 138 ms
29,804 KB
testcase_09 AC 146 ms
29,832 KB
testcase_10 AC 141 ms
29,844 KB
testcase_11 AC 143 ms
30,064 KB
testcase_12 AC 164 ms
30,112 KB
testcase_13 AC 226 ms
30,568 KB
testcase_14 AC 152 ms
30,076 KB
testcase_15 AC 155 ms
30,140 KB
testcase_16 AC 169 ms
30,284 KB
testcase_17 AC 195 ms
30,640 KB
testcase_18 AC 138 ms
29,840 KB
testcase_19 AC 139 ms
29,728 KB
testcase_20 AC 136 ms
29,724 KB
testcase_21 AC 140 ms
30,004 KB
testcase_22 AC 139 ms
29,728 KB
testcase_23 AC 138 ms
29,800 KB
testcase_24 AC 244 ms
30,580 KB
testcase_25 AC 243 ms
30,604 KB
testcase_26 AC 242 ms
30,764 KB
testcase_27 AC 244 ms
30,804 KB
testcase_28 AC 234 ms
30,916 KB
testcase_29 AC 232 ms
30,904 KB
testcase_30 AC 136 ms
29,852 KB
testcase_31 AC 137 ms
29,776 KB
testcase_32 AC 138 ms
29,832 KB
testcase_33 AC 138 ms
29,788 KB
testcase_34 AC 138 ms
30,004 KB
testcase_35 AC 245 ms
30,360 KB
testcase_36 AC 242 ms
30,412 KB
testcase_37 AC 245 ms
30,480 KB
testcase_38 AC 244 ms
30,512 KB
testcase_39 AC 244 ms
30,496 KB
testcase_40 AC 242 ms
30,780 KB
testcase_41 AC 243 ms
30,736 KB
testcase_42 AC 241 ms
30,608 KB
testcase_43 AC 247 ms
30,748 KB
testcase_44 AC 244 ms
30,616 KB
testcase_45 AC 245 ms
30,756 KB
testcase_46 AC 231 ms
30,980 KB
testcase_47 AC 233 ms
30,916 KB
testcase_48 AC 233 ms
30,880 KB
testcase_49 AC 232 ms
30,792 KB
testcase_50 AC 234 ms
30,944 KB
testcase_51 AC 232 ms
30,980 KB
testcase_52 AC 232 ms
30,464 KB
testcase_53 AC 242 ms
30,636 KB
testcase_54 AC 212 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, K = map(int, input().split())
INF = 10 ** 9
pizza = [tuple(map(int, input().split())) for _ in range(N)]
pizza.sort(key=lambda x: -x[0])

dp0 = np.zeros(K + 1, dtype=int)
dp1 = np.full(K + 1, -INF, dtype=int)
for p, d in pizza:
    new_dp0 = dp0.copy()
    new_dp1 = dp1.copy()
    new_dp1[p:] = np.maximum(new_dp1[p:], dp0[:-p] + d)
    new_dp0 = np.maximum(new_dp0, dp1 + d)
    dp0 = new_dp0
    dp1 = new_dp1
print(max(dp0.max(), dp1.max()))
0