結果

問題 No.1858 Gorgeous Knapsack
ユーザー ysys
提出日時 2022-03-06 23:10:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 76,648 KB
最終ジャッジ日時 2023-09-28 14:55:15
合計ジャッジ時間 7,354 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,116 KB
testcase_01 AC 78 ms
70,976 KB
testcase_02 AC 75 ms
71,168 KB
testcase_03 AC 86 ms
75,812 KB
testcase_04 AC 153 ms
76,300 KB
testcase_05 AC 97 ms
76,432 KB
testcase_06 AC 159 ms
76,616 KB
testcase_07 AC 123 ms
76,164 KB
testcase_08 AC 191 ms
76,600 KB
testcase_09 AC 259 ms
76,604 KB
testcase_10 AC 145 ms
76,556 KB
testcase_11 AC 176 ms
76,584 KB
testcase_12 AC 224 ms
76,300 KB
testcase_13 AC 106 ms
76,548 KB
testcase_14 AC 82 ms
75,920 KB
testcase_15 AC 79 ms
75,768 KB
testcase_16 AC 81 ms
75,808 KB
testcase_17 AC 76 ms
71,032 KB
testcase_18 AC 78 ms
71,348 KB
testcase_19 AC 76 ms
71,212 KB
testcase_20 AC 76 ms
71,036 KB
testcase_21 AC 77 ms
71,032 KB
testcase_22 AC 75 ms
71,184 KB
testcase_23 AC 75 ms
71,216 KB
testcase_24 AC 104 ms
76,388 KB
testcase_25 AC 186 ms
76,604 KB
testcase_26 AC 183 ms
76,648 KB
testcase_27 AC 174 ms
76,612 KB
testcase_28 AC 139 ms
76,628 KB
testcase_29 AC 93 ms
76,584 KB
testcase_30 AC 96 ms
76,384 KB
testcase_31 AC 93 ms
76,292 KB
testcase_32 AC 93 ms
76,156 KB
testcase_33 AC 97 ms
76,224 KB
testcase_34 AC 168 ms
76,536 KB
testcase_35 AC 171 ms
76,280 KB
testcase_36 AC 165 ms
76,592 KB
testcase_37 AC 74 ms
71,144 KB
testcase_38 AC 86 ms
76,116 KB
testcase_39 AC 77 ms
71,120 KB
testcase_40 AC 169 ms
76,548 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 = [-1] * (M + 1)
dp[0] = 0
T.sort(reverse=True)
ans = 0
TW = 0
for i in range(N):
  v, w = T[i]
  TW += w
  for j in range(min(M, TW + 1), -1, -1):
    if dp[j] != -1 and j + w <= M:
      dp[j + w] = max(dp[j + w], dp[j] + v)
      ans = max(ans, dp[j + w] * v)

print(ans)
0