結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー NoaSaberNoaSaber
提出日時 2021-03-11 18:04:43
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 560 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 722,064 KB
最終ジャッジ日時 2024-04-21 07:15:47
合計ジャッジ時間 49,469 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,224 KB
testcase_01 AC 35 ms
52,480 KB
testcase_02 AC 69 ms
64,256 KB
testcase_03 AC 45 ms
60,288 KB
testcase_04 AC 37 ms
52,492 KB
testcase_05 AC 36 ms
51,968 KB
testcase_06 AC 51 ms
65,536 KB
testcase_07 AC 36 ms
52,480 KB
testcase_08 AC 48 ms
62,720 KB
testcase_09 AC 141 ms
90,276 KB
testcase_10 AC 128 ms
85,248 KB
testcase_11 AC 112 ms
82,176 KB
testcase_12 AC 424 ms
216,848 KB
testcase_13 MLE -
testcase_14 AC 501 ms
151,232 KB
testcase_15 AC 321 ms
172,536 KB
testcase_16 AC 404 ms
212,772 KB
testcase_17 AC 485 ms
255,332 KB
testcase_18 AC 38 ms
52,608 KB
testcase_19 AC 35 ms
52,608 KB
testcase_20 AC 37 ms
52,096 KB
testcase_21 AC 112 ms
81,340 KB
testcase_22 AC 101 ms
78,244 KB
testcase_23 AC 101 ms
79,356 KB
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 MLE -
testcase_28 MLE -
testcase_29 MLE -
testcase_30 AC 38 ms
53,084 KB
testcase_31 AC 38 ms
52,764 KB
testcase_32 AC 106 ms
78,564 KB
testcase_33 AC 111 ms
80,052 KB
testcase_34 AC 134 ms
89,228 KB
testcase_35 MLE -
testcase_36 MLE -
testcase_37 MLE -
testcase_38 MLE -
testcase_39 MLE -
testcase_40 MLE -
testcase_41 MLE -
testcase_42 MLE -
testcase_43 MLE -
testcase_44 MLE -
testcase_45 MLE -
testcase_46 MLE -
testcase_47 MLE -
testcase_48 MLE -
testcase_49 MLE -
testcase_50 MLE -
testcase_51 MLE -
testcase_52 MLE -
testcase_53 MLE -
testcase_54 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
pd=[]
dp0,dp1=[[-float("inf")]*(K+1) for i in range(N+1)],[[-float("inf")]*(K+1) for i in range(N+1)]
dp0[0][0]=0
for i in range(N):
    pd.append(list(map(int,input().split())))
pd.sort(reverse=True)
for i in range(N):
    cost,value=pd[i]
    for j in range(K+1):
        dp0[i+1][j]=max(dp0[i][j],dp1[i][j]+value)
        dp1[i+1][j]=max(dp1[i][j],dp1[i+1][j])
        if cost+j<=K:
            dp1[i+1][j+cost]=max(dp0[i][j]+value,dp1[i][j]+value)
ans=-1
for i in range(1,K+1):
    ans=max(ans,dp0[-1][i],dp1[-1][i])
print(ans)
0