結果

問題 No.1858 Gorgeous Knapsack
ユーザー ytftytft
提出日時 2022-03-14 12:45:04
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 489 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 471,256 KB
最終ジャッジ日時 2023-10-20 02:59:31
合計ジャッジ時間 19,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,376 KB
testcase_01 AC 36 ms
53,376 KB
testcase_02 AC 36 ms
53,376 KB
testcase_03 AC 60 ms
68,356 KB
testcase_04 AC 468 ms
144,636 KB
testcase_05 AC 153 ms
90,176 KB
testcase_06 AC 549 ms
167,532 KB
testcase_07 AC 320 ms
120,176 KB
testcase_08 AC 764 ms
206,616 KB
testcase_09 AC 1,312 ms
299,096 KB
testcase_10 AC 384 ms
133,976 KB
testcase_11 AC 604 ms
173,956 KB
testcase_12 AC 951 ms
245,232 KB
testcase_13 AC 142 ms
85,608 KB
testcase_14 AC 51 ms
64,212 KB
testcase_15 AC 44 ms
62,088 KB
testcase_16 AC 47 ms
62,124 KB
testcase_17 AC 38 ms
53,376 KB
testcase_18 AC 38 ms
53,376 KB
testcase_19 AC 37 ms
53,376 KB
testcase_20 AC 37 ms
53,376 KB
testcase_21 AC 36 ms
53,376 KB
testcase_22 AC 36 ms
53,376 KB
testcase_23 AC 36 ms
53,376 KB
testcase_24 AC 206 ms
91,584 KB
testcase_25 AC 874 ms
234,272 KB
testcase_26 AC 721 ms
204,836 KB
testcase_27 AC 701 ms
196,364 KB
testcase_28 AC 500 ms
153,824 KB
testcase_29 AC 74 ms
76,472 KB
testcase_30 AC 72 ms
76,616 KB
testcase_31 AC 73 ms
76,708 KB
testcase_32 AC 65 ms
72,972 KB
testcase_33 AC 77 ms
77,164 KB
testcase_34 TLE -
testcase_35 AC 1,575 ms
407,484 KB
testcase_36 AC 1,746 ms
386,400 KB
testcase_37 AC 37 ms
53,364 KB
testcase_38 AC 70 ms
76,896 KB
testcase_39 AC 44 ms
60,024 KB
testcase_40 AC 1,555 ms
407,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda:sys.stdin.readline().rstrip()
N,M=map(int,input().split())
jewel=[tuple(map(int,input().split())) for i in range(N)]
jewel=sorted(jewel,key=lambda x:-x[0])
dp=[[-float('inf') for i in range(M+1)] for j in range(N+1)]
dp[0][0]=0
ans=0
for i in range(1,N+1):
	V,W=jewel[i-1]
	Mx=-float('inf')
	for j in range(M+1):
		if j-W>=0 and dp[i-1][j-W]+V>dp[i-1][j]:
			dp[i][j]=dp[i-1][j-W]+V
		else:
			dp[i][j]=dp[i-1][j]
		Mx=max(Mx,dp[i][j])
	ans=max(ans,V*Mx)
print(ans)
0