結果

問題 No.1858 Gorgeous Knapsack
ユーザー ytftytft
提出日時 2022-03-14 12:43:28
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 457 bytes
コンパイル時間 874 ms
コンパイル使用メモリ 81,604 KB
実行使用メモリ 462,148 KB
最終ジャッジ日時 2023-10-20 02:57:38
合計ジャッジ時間 19,808 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,424 KB
testcase_01 AC 37 ms
53,424 KB
testcase_02 AC 37 ms
53,424 KB
testcase_03 AC 65 ms
68,544 KB
testcase_04 AC 483 ms
147,372 KB
testcase_05 AC 138 ms
83,672 KB
testcase_06 AC 537 ms
155,884 KB
testcase_07 AC 325 ms
122,052 KB
testcase_08 AC 765 ms
208,844 KB
testcase_09 AC 1,296 ms
300,208 KB
testcase_10 AC 374 ms
127,308 KB
testcase_11 AC 569 ms
174,912 KB
testcase_12 AC 985 ms
245,932 KB
testcase_13 AC 137 ms
86,084 KB
testcase_14 AC 53 ms
66,488 KB
testcase_15 AC 44 ms
62,304 KB
testcase_16 AC 48 ms
64,404 KB
testcase_17 AC 37 ms
53,424 KB
testcase_18 AC 38 ms
53,424 KB
testcase_19 AC 37 ms
53,424 KB
testcase_20 AC 36 ms
53,424 KB
testcase_21 AC 37 ms
53,424 KB
testcase_22 AC 36 ms
53,424 KB
testcase_23 AC 38 ms
53,424 KB
testcase_24 AC 204 ms
92,060 KB
testcase_25 AC 897 ms
235,492 KB
testcase_26 AC 725 ms
207,580 KB
testcase_27 AC 698 ms
199,212 KB
testcase_28 AC 471 ms
155,340 KB
testcase_29 AC 73 ms
76,624 KB
testcase_30 AC 71 ms
76,768 KB
testcase_31 AC 72 ms
76,788 KB
testcase_32 AC 65 ms
73,528 KB
testcase_33 AC 78 ms
77,304 KB
testcase_34 TLE -
testcase_35 AC 1,513 ms
428,888 KB
testcase_36 AC 1,775 ms
396,368 KB
testcase_37 AC 36 ms
53,440 KB
testcase_38 AC 69 ms
77,072 KB
testcase_39 AC 43 ms
60,276 KB
testcase_40 AC 1,510 ms
428,888 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]
	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]
	ans=max(ans,V*max(dp[i]))
print(ans)
0