結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-04 13:37:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 30,776 KB
最終ジャッジ日時 2023-10-13 01:51:54
合計ジャッジ時間 13,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
29,680 KB
testcase_01 AC 133 ms
29,712 KB
testcase_02 AC 134 ms
29,672 KB
testcase_03 AC 138 ms
29,728 KB
testcase_04 AC 133 ms
29,688 KB
testcase_05 AC 130 ms
29,708 KB
testcase_06 AC 131 ms
29,812 KB
testcase_07 AC 131 ms
29,728 KB
testcase_08 AC 131 ms
29,712 KB
testcase_09 AC 136 ms
29,760 KB
testcase_10 AC 135 ms
29,808 KB
testcase_11 AC 138 ms
29,888 KB
testcase_12 AC 154 ms
29,956 KB
testcase_13 AC 219 ms
30,360 KB
testcase_14 AC 145 ms
29,908 KB
testcase_15 AC 150 ms
29,996 KB
testcase_16 AC 161 ms
30,112 KB
testcase_17 AC 189 ms
30,364 KB
testcase_18 AC 131 ms
29,696 KB
testcase_19 AC 132 ms
29,700 KB
testcase_20 AC 135 ms
29,692 KB
testcase_21 AC 134 ms
29,864 KB
testcase_22 AC 134 ms
29,640 KB
testcase_23 AC 133 ms
29,824 KB
testcase_24 AC 241 ms
30,452 KB
testcase_25 AC 242 ms
30,400 KB
testcase_26 AC 244 ms
30,660 KB
testcase_27 AC 239 ms
30,528 KB
testcase_28 AC 235 ms
30,776 KB
testcase_29 AC 233 ms
30,680 KB
testcase_30 AC 133 ms
29,740 KB
testcase_31 AC 133 ms
29,696 KB
testcase_32 AC 134 ms
29,732 KB
testcase_33 AC 135 ms
29,760 KB
testcase_34 AC 138 ms
30,048 KB
testcase_35 AC 242 ms
30,284 KB
testcase_36 AC 237 ms
30,244 KB
testcase_37 AC 246 ms
30,272 KB
testcase_38 AC 244 ms
30,244 KB
testcase_39 AC 240 ms
30,248 KB
testcase_40 AC 241 ms
30,504 KB
testcase_41 AC 242 ms
30,480 KB
testcase_42 AC 239 ms
30,540 KB
testcase_43 AC 239 ms
30,488 KB
testcase_44 AC 240 ms
30,544 KB
testcase_45 AC 239 ms
30,576 KB
testcase_46 AC 229 ms
30,708 KB
testcase_47 AC 228 ms
30,616 KB
testcase_48 AC 231 ms
30,672 KB
testcase_49 AC 232 ms
30,620 KB
testcase_50 AC 231 ms
30,720 KB
testcase_51 AC 232 ms
30,668 KB
testcase_52 AC 230 ms
30,320 KB
testcase_53 AC 245 ms
30,448 KB
testcase_54 AC 215 ms
30,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys
input = sys.stdin.buffer.readline
inf = 10**18

N, K = map(int, input().split())
PD = list(tuple(map(int, input().split())) for _ in range(N))
PD.sort(reverse=True)

dp0 = np.full(K + 1, -inf, dtype=np.int64)
dp1 = np.full_like(dp0, -inf)
dp0[0] = 0

for p, d in PD:
    newDP0 = np.copy(dp0)
    newDP1 = np.copy(dp1)
    newDP1[p:] = np.maximum(newDP1[p:], dp0[:-p] + d)
    newDP0 = np.maximum(newDP0, dp1 + d)
    dp0 = newDP0
    dp1 = newDP1

ans = max(dp0.max(), dp1.max())
print(ans)
0