結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー neterukunneterukun
提出日時 2020-01-01 21:32:21
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 709 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 82,592 KB
実行使用メモリ 849,428 KB
最終ジャッジ日時 2024-05-02 05:54:08
合計ジャッジ時間 5,720 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,096 KB
testcase_01 AC 36 ms
52,864 KB
testcase_02 AC 53 ms
66,432 KB
testcase_03 AC 42 ms
61,696 KB
testcase_04 AC 34 ms
52,608 KB
testcase_05 AC 33 ms
52,608 KB
testcase_06 AC 54 ms
67,968 KB
testcase_07 AC 35 ms
52,608 KB
testcase_08 AC 48 ms
64,000 KB
testcase_09 AC 172 ms
125,568 KB
testcase_10 AC 126 ms
103,736 KB
testcase_11 AC 128 ms
105,156 KB
testcase_12 AC 1,345 ms
504,808 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]
info = sorted(info, reverse = True)

dp = [[[0]*2 for _ in range(k+1)] for i in range(n+1)]

for i in range(n):
    cost, val = info[i]
    for j in range(k+1):
        # i番目を無料としてもらう
        if dp[i][j][1] != 0:
            dp[i+1][j][0] = max(dp[i][j][1] + val, dp[i+1][j][0])
        # i番目をお金を払ってもらう
        if j - cost >= 0:
            dp[i+1][j][1] = max(dp[i][j - cost][0] + val, dp[i+1][j][1])
        # i番目をもらわない
        dp[i+1][j][0] = max(dp[i][j][0], dp[i+1][j][0])
        dp[i+1][j][1] = max(dp[i][j][1], dp[i+1][j][1])

print(max(dp[n][k]))
0