結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー ttrttr
提出日時 2020-01-30 21:05:59
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 660 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 846,864 KB
最終ジャッジ日時 2023-10-14 08:46:33
合計ジャッジ時間 7,316 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,120 KB
testcase_01 AC 75 ms
71,520 KB
testcase_02 AC 94 ms
76,788 KB
testcase_03 AC 82 ms
76,236 KB
testcase_04 AC 75 ms
71,384 KB
testcase_05 AC 74 ms
71,240 KB
testcase_06 AC 94 ms
76,952 KB
testcase_07 AC 73 ms
71,316 KB
testcase_08 AC 88 ms
76,468 KB
testcase_09 AC 216 ms
126,532 KB
testcase_10 AC 167 ms
104,920 KB
testcase_11 AC 166 ms
106,156 KB
testcase_12 AC 1,414 ms
498,068 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())
L = [[int(l) for l in input().split()] for _ in range(N)]

L.sort(reverse=True)
dp = [[[0]*2 for _ in range(K+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(K+1):
        if j < L[i][0] and dp[i][j][1] > 0:
            dp[i+1][j][0] = max(dp[i][j][0], dp[i][j][1]+L[i][1])
        elif j < L[i][0]:
            dp[i+1][j][0] = dp[i][j][0]
        else:
            if dp[i][j][1] > 0:
                dp[i+1][j][0] = max(dp[i][j][0], dp[i][j][1]+L[i][1])
            else:
                dp[i+1][j][0] = dp[i][j][0]
            dp[i+1][j][1] = max(dp[i][j][1], dp[i][j-L[i][0]][0]+L[i][1])

print(max(dp[N][K]))
0