結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー rlangevinrlangevin
提出日時 2023-09-25 08:56:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 949 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 82,024 KB
最終ジャッジ日時 2023-09-25 08:57:17
合計ジャッジ時間 26,689 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,316 KB
testcase_01 AC 82 ms
71,240 KB
testcase_02 AC 123 ms
75,896 KB
testcase_03 AC 79 ms
76,084 KB
testcase_04 AC 76 ms
71,576 KB
testcase_05 AC 74 ms
71,308 KB
testcase_06 AC 85 ms
76,032 KB
testcase_07 AC 74 ms
71,392 KB
testcase_08 AC 82 ms
75,888 KB
testcase_09 AC 158 ms
77,120 KB
testcase_10 AC 112 ms
76,900 KB
testcase_11 AC 110 ms
77,440 KB
testcase_12 AC 243 ms
78,716 KB
testcase_13 AC 587 ms
79,900 KB
testcase_14 AC 164 ms
77,776 KB
testcase_15 AC 170 ms
77,760 KB
testcase_16 AC 295 ms
78,340 KB
testcase_17 AC 230 ms
78,068 KB
testcase_18 AC 73 ms
71,288 KB
testcase_19 AC 73 ms
71,252 KB
testcase_20 AC 73 ms
71,304 KB
testcase_21 AC 101 ms
76,936 KB
testcase_22 AC 105 ms
75,984 KB
testcase_23 AC 96 ms
76,168 KB
testcase_24 AC 556 ms
81,488 KB
testcase_25 AC 799 ms
81,760 KB
testcase_26 AC 845 ms
81,552 KB
testcase_27 AC 866 ms
81,804 KB
testcase_28 AC 797 ms
81,768 KB
testcase_29 AC 569 ms
81,588 KB
testcase_30 AC 74 ms
71,140 KB
testcase_31 AC 75 ms
71,484 KB
testcase_32 AC 100 ms
76,008 KB
testcase_33 AC 106 ms
76,072 KB
testcase_34 AC 111 ms
76,832 KB
testcase_35 AC 639 ms
81,432 KB
testcase_36 AC 668 ms
81,536 KB
testcase_37 AC 901 ms
81,712 KB
testcase_38 AC 927 ms
81,560 KB
testcase_39 AC 921 ms
81,420 KB
testcase_40 AC 949 ms
81,688 KB
testcase_41 AC 914 ms
81,784 KB
testcase_42 AC 937 ms
81,708 KB
testcase_43 AC 934 ms
81,352 KB
testcase_44 AC 930 ms
81,400 KB
testcase_45 AC 903 ms
81,556 KB
testcase_46 AC 595 ms
81,736 KB
testcase_47 AC 562 ms
81,568 KB
testcase_48 AC 572 ms
81,860 KB
testcase_49 AC 552 ms
81,664 KB
testcase_50 AC 576 ms
81,588 KB
testcase_51 AC 554 ms
81,636 KB
testcase_52 AC 420 ms
80,692 KB
testcase_53 AC 461 ms
82,024 KB
testcase_54 AC 344 ms
81,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
inf = 10 ** 18
pre0 = [-inf] * (K + 1)
pre1 = [-inf] * (K + 1)
pre0[0] = 0
S = []
for _ in range(N):
    P, D = map(int, input().split())
    S.append((-P, -D))
S.sort()

for P, D in S:
    P, D = -P, -D
    dp0 = [-inf] * (K + 1)
    dp1 = [-inf] * (K + 1)
    for i in range(K + 1):
        dp0[i] = max(dp0[i], pre0[i], pre1[i] + D)
        dp1[i] = max(dp1[i], pre1[i])
        if i - P >= 0:
            dp1[i] = max(dp1[i], pre0[i - P] + D)
    dp0, pre0 = pre0, dp0
    dp1, pre1 = pre1, dp1

print(max(pre0 + pre1))
0