結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー ttrttr
提出日時 2020-01-30 21:17:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,705 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 470,148 KB
最終ジャッジ日時 2023-10-14 08:48:34
合計ジャッジ時間 40,444 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,456 KB
testcase_01 AC 72 ms
71,372 KB
testcase_02 AC 86 ms
76,112 KB
testcase_03 AC 81 ms
76,060 KB
testcase_04 AC 73 ms
71,280 KB
testcase_05 AC 74 ms
71,224 KB
testcase_06 AC 90 ms
76,204 KB
testcase_07 AC 73 ms
71,324 KB
testcase_08 AC 82 ms
76,132 KB
testcase_09 AC 127 ms
86,496 KB
testcase_10 AC 114 ms
81,820 KB
testcase_11 AC 114 ms
82,588 KB
testcase_12 AC 381 ms
150,920 KB
testcase_13 AC 1,130 ms
351,648 KB
testcase_14 AC 246 ms
112,848 KB
testcase_15 AC 245 ms
125,448 KB
testcase_16 AC 288 ms
148,608 KB
testcase_17 AC 327 ms
165,696 KB
testcase_18 AC 74 ms
71,196 KB
testcase_19 AC 74 ms
71,424 KB
testcase_20 AC 72 ms
71,196 KB
testcase_21 AC 114 ms
81,632 KB
testcase_22 AC 100 ms
76,668 KB
testcase_23 AC 102 ms
76,608 KB
testcase_24 AC 1,467 ms
470,072 KB
testcase_25 AC 1,532 ms
469,940 KB
testcase_26 AC 1,300 ms
469,720 KB
testcase_27 AC 1,323 ms
470,148 KB
testcase_28 AC 981 ms
469,768 KB
testcase_29 AC 1,000 ms
469,872 KB
testcase_30 AC 72 ms
71,292 KB
testcase_31 AC 72 ms
71,356 KB
testcase_32 AC 102 ms
76,812 KB
testcase_33 AC 103 ms
76,472 KB
testcase_34 AC 120 ms
84,608 KB
testcase_35 AC 1,606 ms
469,880 KB
testcase_36 AC 1,611 ms
469,688 KB
testcase_37 AC 1,672 ms
470,040 KB
testcase_38 AC 1,705 ms
469,908 KB
testcase_39 AC 1,618 ms
469,700 KB
testcase_40 AC 1,379 ms
470,060 KB
testcase_41 AC 1,345 ms
470,060 KB
testcase_42 AC 1,392 ms
469,728 KB
testcase_43 AC 1,348 ms
469,948 KB
testcase_44 AC 1,353 ms
469,972 KB
testcase_45 AC 1,318 ms
470,040 KB
testcase_46 AC 1,011 ms
469,576 KB
testcase_47 AC 983 ms
469,880 KB
testcase_48 AC 987 ms
469,808 KB
testcase_49 AC 973 ms
469,876 KB
testcase_50 AC 977 ms
469,544 KB
testcase_51 AC 972 ms
469,768 KB
testcase_52 AC 1,094 ms
393,116 KB
testcase_53 AC 1,319 ms
469,992 KB
testcase_54 AC 758 ms
469,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int, input().split())
L = []
for _ in range(N):
    p,d = map(int, input().split())
    L.append((p, d))

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

print(max(dp0[N][K], dp1[N][K]))
0