結果

問題 No.1858 Gorgeous Knapsack
ユーザー qibqib
提出日時 2022-11-23 18:19:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 467 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 1,120 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 76,844 KB
最終ジャッジ日時 2023-10-25 03:46:26
合計ジャッジ時間 7,817 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,456 KB
testcase_01 AC 39 ms
53,456 KB
testcase_02 AC 38 ms
53,456 KB
testcase_03 AC 50 ms
63,876 KB
testcase_04 AC 131 ms
76,204 KB
testcase_05 AC 69 ms
72,624 KB
testcase_06 AC 127 ms
76,284 KB
testcase_07 AC 103 ms
76,560 KB
testcase_08 AC 145 ms
76,456 KB
testcase_09 AC 185 ms
76,696 KB
testcase_10 AC 111 ms
76,768 KB
testcase_11 AC 133 ms
76,684 KB
testcase_12 AC 162 ms
76,680 KB
testcase_13 AC 91 ms
76,732 KB
testcase_14 AC 45 ms
59,700 KB
testcase_15 AC 40 ms
53,460 KB
testcase_16 AC 44 ms
59,628 KB
testcase_17 AC 39 ms
53,460 KB
testcase_18 AC 39 ms
53,460 KB
testcase_19 AC 39 ms
53,460 KB
testcase_20 AC 38 ms
53,460 KB
testcase_21 AC 37 ms
53,460 KB
testcase_22 AC 38 ms
53,460 KB
testcase_23 AC 38 ms
53,460 KB
testcase_24 AC 84 ms
75,680 KB
testcase_25 AC 133 ms
76,844 KB
testcase_26 AC 141 ms
76,324 KB
testcase_27 AC 133 ms
76,280 KB
testcase_28 AC 110 ms
76,648 KB
testcase_29 AC 74 ms
72,964 KB
testcase_30 AC 83 ms
76,388 KB
testcase_31 AC 76 ms
73,272 KB
testcase_32 AC 77 ms
72,992 KB
testcase_33 AC 81 ms
76,404 KB
testcase_34 AC 467 ms
76,788 KB
testcase_35 AC 80 ms
76,464 KB
testcase_36 AC 270 ms
76,808 KB
testcase_37 AC 38 ms
53,460 KB
testcase_38 AC 79 ms
76,480 KB
testcase_39 AC 43 ms
59,688 KB
testcase_40 AC 82 ms
76,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1 << 60

n, m = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(n)]

items.sort(key=lambda x: x[0])

ans = 0
dp = [- INF for _ in range(m + 1)]
dp[0] = 0
for _ in range(n):
  v, w = items.pop()
  for i in range(m - w, -1, -1):
    ans = max(ans, v * (dp[i] + v))
    dp[i + w] = max(dp[i + w], dp[i] + v)

print(ans)
0