結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー 👑 H20H20
提出日時 2022-04-13 13:26:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,092 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 79,404 KB
最終ジャッジ日時 2023-08-24 23:34:37
合計ジャッジ時間 27,694 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,300 KB
testcase_01 AC 73 ms
71,500 KB
testcase_02 AC 97 ms
76,228 KB
testcase_03 AC 76 ms
75,800 KB
testcase_04 AC 74 ms
71,424 KB
testcase_05 AC 74 ms
71,252 KB
testcase_06 AC 85 ms
76,136 KB
testcase_07 AC 74 ms
71,380 KB
testcase_08 AC 81 ms
76,000 KB
testcase_09 AC 132 ms
77,648 KB
testcase_10 AC 113 ms
77,044 KB
testcase_11 AC 110 ms
77,352 KB
testcase_12 AC 278 ms
78,744 KB
testcase_13 AC 669 ms
79,276 KB
testcase_14 AC 205 ms
78,260 KB
testcase_15 AC 176 ms
77,976 KB
testcase_16 AC 221 ms
78,940 KB
testcase_17 AC 257 ms
78,800 KB
testcase_18 AC 78 ms
71,444 KB
testcase_19 AC 77 ms
71,136 KB
testcase_20 AC 75 ms
71,436 KB
testcase_21 AC 115 ms
77,376 KB
testcase_22 AC 112 ms
77,104 KB
testcase_23 AC 116 ms
77,136 KB
testcase_24 AC 862 ms
79,152 KB
testcase_25 AC 910 ms
79,200 KB
testcase_26 AC 745 ms
78,968 KB
testcase_27 AC 752 ms
79,032 KB
testcase_28 AC 610 ms
79,376 KB
testcase_29 AC 585 ms
79,188 KB
testcase_30 AC 76 ms
71,432 KB
testcase_31 AC 77 ms
71,428 KB
testcase_32 AC 113 ms
77,236 KB
testcase_33 AC 117 ms
77,528 KB
testcase_34 AC 115 ms
77,448 KB
testcase_35 AC 903 ms
79,268 KB
testcase_36 AC 921 ms
79,132 KB
testcase_37 AC 768 ms
79,404 KB
testcase_38 AC 1,084 ms
79,260 KB
testcase_39 AC 1,092 ms
79,104 KB
testcase_40 AC 710 ms
79,092 KB
testcase_41 AC 782 ms
78,964 KB
testcase_42 AC 717 ms
78,908 KB
testcase_43 AC 716 ms
79,128 KB
testcase_44 AC 710 ms
78,904 KB
testcase_45 AC 840 ms
78,912 KB
testcase_46 AC 577 ms
78,920 KB
testcase_47 AC 597 ms
78,944 KB
testcase_48 AC 580 ms
79,316 KB
testcase_49 AC 565 ms
79,072 KB
testcase_50 AC 620 ms
79,024 KB
testcase_51 AC 580 ms
79,140 KB
testcase_52 AC 396 ms
78,784 KB
testcase_53 AC 432 ms
78,968 KB
testcase_54 AC 314 ms
78,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
PD = [list(map(int,input().split())) for _ in range(N)]
PD = sorted(PD,reverse=True)
DP = [[-1]*2 for _ in range(K+1)]
DP[0][0]=0
for p,d in PD:
    for i in reversed(range(K+1)):
        if DP[i][0]>=0 and i+p<=K:
            DP[i+p][1] = max(DP[i+p][1],DP[i][0]+d)
        if DP[i][1]>=0:
            DP[i][0] = max(DP[i][0],DP[i][1]+d)
ans = 0
for dp in DP:
    ans = max(ans,max(dp))
print(ans)
0