結果

問題 No.1858 Gorgeous Knapsack
ユーザー ysys
提出日時 2022-03-06 23:01:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 773 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 273,956 KB
最終ジャッジ日時 2023-09-28 14:43:15
合計ジャッジ時間 12,027 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,284 KB
testcase_01 AC 74 ms
71,460 KB
testcase_02 AC 74 ms
71,048 KB
testcase_03 AC 97 ms
76,100 KB
testcase_04 AC 245 ms
111,224 KB
testcase_05 AC 121 ms
84,428 KB
testcase_06 AC 275 ms
110,448 KB
testcase_07 AC 189 ms
103,800 KB
testcase_08 AC 287 ms
132,828 KB
testcase_09 AC 540 ms
191,760 KB
testcase_10 AC 274 ms
106,680 KB
testcase_11 AC 306 ms
129,688 KB
testcase_12 AC 361 ms
166,588 KB
testcase_13 AC 123 ms
82,712 KB
testcase_14 AC 83 ms
76,012 KB
testcase_15 AC 85 ms
76,076 KB
testcase_16 AC 81 ms
75,984 KB
testcase_17 AC 75 ms
71,324 KB
testcase_18 AC 76 ms
71,408 KB
testcase_19 AC 76 ms
71,496 KB
testcase_20 AC 76 ms
71,492 KB
testcase_21 AC 75 ms
71,492 KB
testcase_22 AC 76 ms
71,180 KB
testcase_23 AC 75 ms
71,180 KB
testcase_24 AC 149 ms
90,444 KB
testcase_25 AC 383 ms
153,988 KB
testcase_26 AC 321 ms
133,188 KB
testcase_27 AC 315 ms
133,336 KB
testcase_28 AC 228 ms
108,552 KB
testcase_29 AC 92 ms
76,784 KB
testcase_30 AC 93 ms
76,760 KB
testcase_31 AC 95 ms
76,512 KB
testcase_32 AC 91 ms
76,712 KB
testcase_33 AC 97 ms
76,856 KB
testcase_34 AC 773 ms
272,916 KB
testcase_35 AC 587 ms
273,628 KB
testcase_36 AC 697 ms
273,956 KB
testcase_37 AC 72 ms
71,092 KB
testcase_38 AC 89 ms
76,472 KB
testcase_39 AC 79 ms
75,852 KB
testcase_40 AC 461 ms
273,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
T = [tuple(map(int, input().split())) for i in range(N)]
dp = [[0] * (M + 1) for i in range(N + 1)]
T.sort(reverse=True)
ans = 0
for i in range(N):
  v, w = T[i]
  for j in range(M):
    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
    if j + w <= M:
      dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v)
      ans = max(ans, dp[i + 1][j + w] * v)

print(ans)
0