結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー りあんりあん
提出日時 2019-12-12 23:41:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 790 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 79,584 KB
最終ジャッジ日時 2023-09-09 23:46:21
合計ジャッジ時間 21,819 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,192 KB
testcase_01 AC 74 ms
71,452 KB
testcase_02 AC 88 ms
75,988 KB
testcase_03 AC 77 ms
76,152 KB
testcase_04 AC 72 ms
71,040 KB
testcase_05 AC 76 ms
71,544 KB
testcase_06 AC 86 ms
76,096 KB
testcase_07 AC 76 ms
71,236 KB
testcase_08 AC 79 ms
75,772 KB
testcase_09 AC 120 ms
76,868 KB
testcase_10 AC 107 ms
76,484 KB
testcase_11 AC 107 ms
76,636 KB
testcase_12 AC 222 ms
78,464 KB
testcase_13 AC 492 ms
78,824 KB
testcase_14 AC 176 ms
78,140 KB
testcase_15 AC 164 ms
78,028 KB
testcase_16 AC 218 ms
78,300 KB
testcase_17 AC 214 ms
78,292 KB
testcase_18 AC 72 ms
71,204 KB
testcase_19 AC 73 ms
71,040 KB
testcase_20 AC 73 ms
71,332 KB
testcase_21 AC 101 ms
76,584 KB
testcase_22 AC 97 ms
76,468 KB
testcase_23 AC 101 ms
76,436 KB
testcase_24 AC 605 ms
78,920 KB
testcase_25 AC 620 ms
79,044 KB
testcase_26 AC 685 ms
78,228 KB
testcase_27 AC 693 ms
79,424 KB
testcase_28 AC 622 ms
78,464 KB
testcase_29 AC 478 ms
78,300 KB
testcase_30 AC 73 ms
71,200 KB
testcase_31 AC 73 ms
71,512 KB
testcase_32 AC 102 ms
76,440 KB
testcase_33 AC 105 ms
77,012 KB
testcase_34 AC 111 ms
77,704 KB
testcase_35 AC 760 ms
78,856 KB
testcase_36 AC 774 ms
79,228 KB
testcase_37 AC 790 ms
78,808 KB
testcase_38 AC 674 ms
78,956 KB
testcase_39 AC 677 ms
79,000 KB
testcase_40 AC 667 ms
78,916 KB
testcase_41 AC 720 ms
78,900 KB
testcase_42 AC 721 ms
79,328 KB
testcase_43 AC 668 ms
79,068 KB
testcase_44 AC 714 ms
79,392 KB
testcase_45 AC 717 ms
79,584 KB
testcase_46 AC 479 ms
78,288 KB
testcase_47 AC 472 ms
78,272 KB
testcase_48 AC 467 ms
78,224 KB
testcase_49 AC 465 ms
78,340 KB
testcase_50 AC 463 ms
78,456 KB
testcase_51 AC 472 ms
78,336 KB
testcase_52 AC 437 ms
78,368 KB
testcase_53 AC 497 ms
78,500 KB
testcase_54 AC 322 ms
78,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
pizza = [ list(map(int, input().split())) for i in range(n) ]
pizza.sort()
pizza.reverse()
dp = [ [ -(1 << 26) ] * 2 for i in range(k + 1) ]
dp[0][0] = 0
for p, d in pizza:
    for i in range(k, -1, -1):
        dp[i][0] = max(dp[i][0], dp[i][1] + d)
        if i >= p:
            dp[i][1] = max(dp[i][1], dp[i - p][0] + d)

print(max([max(i) for i in dp]))
0