結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー AEnAEn
提出日時 2023-05-26 00:34:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,127 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 82,036 KB
最終ジャッジ日時 2023-08-26 01:08:45
合計ジャッジ時間 28,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,088 KB
testcase_01 AC 73 ms
71,232 KB
testcase_02 AC 93 ms
75,992 KB
testcase_03 AC 79 ms
75,836 KB
testcase_04 AC 73 ms
71,100 KB
testcase_05 AC 73 ms
71,088 KB
testcase_06 AC 87 ms
75,912 KB
testcase_07 AC 73 ms
71,404 KB
testcase_08 AC 83 ms
76,012 KB
testcase_09 AC 136 ms
77,232 KB
testcase_10 AC 124 ms
77,096 KB
testcase_11 AC 118 ms
77,620 KB
testcase_12 AC 248 ms
79,216 KB
testcase_13 AC 439 ms
79,920 KB
testcase_14 AC 182 ms
78,456 KB
testcase_15 AC 200 ms
78,196 KB
testcase_16 AC 273 ms
78,436 KB
testcase_17 AC 281 ms
78,972 KB
testcase_18 AC 73 ms
71,500 KB
testcase_19 AC 71 ms
71,324 KB
testcase_20 AC 71 ms
71,136 KB
testcase_21 AC 105 ms
76,944 KB
testcase_22 AC 109 ms
76,868 KB
testcase_23 AC 106 ms
76,664 KB
testcase_24 AC 701 ms
81,168 KB
testcase_25 AC 740 ms
81,604 KB
testcase_26 AC 1,075 ms
80,532 KB
testcase_27 AC 849 ms
81,780 KB
testcase_28 AC 806 ms
80,564 KB
testcase_29 AC 792 ms
80,660 KB
testcase_30 AC 73 ms
71,120 KB
testcase_31 AC 73 ms
71,308 KB
testcase_32 AC 108 ms
76,656 KB
testcase_33 AC 114 ms
76,820 KB
testcase_34 AC 117 ms
77,340 KB
testcase_35 AC 1,099 ms
80,804 KB
testcase_36 AC 834 ms
81,552 KB
testcase_37 AC 1,127 ms
81,136 KB
testcase_38 AC 557 ms
81,564 KB
testcase_39 AC 490 ms
81,160 KB
testcase_40 AC 1,049 ms
81,240 KB
testcase_41 AC 877 ms
81,756 KB
testcase_42 AC 958 ms
82,036 KB
testcase_43 AC 626 ms
81,032 KB
testcase_44 AC 900 ms
81,708 KB
testcase_45 AC 577 ms
81,096 KB
testcase_46 AC 717 ms
80,604 KB
testcase_47 AC 765 ms
80,728 KB
testcase_48 AC 926 ms
80,868 KB
testcase_49 AC 780 ms
80,640 KB
testcase_50 AC 801 ms
80,960 KB
testcase_51 AC 804 ms
80,988 KB
testcase_52 AC 361 ms
80,024 KB
testcase_53 AC 408 ms
80,836 KB
testcase_54 AC 884 ms
80,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
piza = [list(map(int, input().split())) for _ in range(N)]
INF = 10**8

piza.sort(key = lambda x:(-x[0]))
dp = [[-INF]*(K+1) for _ in range(2)]
dp[1][0] = 0
for i in range(N):
    P,D = piza[i]
    ndp = [[-INF]*(K+1) for _ in range(2)]
    for k in range(K+1):
        ndp[0][k] = max(ndp[0][k],dp[0][k])
        ndp[1][k] = max(ndp[1][k],dp[1][k])
        ndp[1][k] = max(ndp[1][k],dp[0][k]+D)
        if k+P<=K:
            ndp[0][k+P] = max(ndp[0][k+P],dp[1][k]+D)
    dp = ndp
res = 0
for i in range(2):
    for j in range(K+1):
        res = max(res,dp[i][j])
print(res)
0