結果

問題 No.1858 Gorgeous Knapsack
ユーザー ShirotsumeShirotsume
提出日時 2022-02-03 17:18:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 478 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 12,136 KB
最終ジャッジ日時 2023-09-17 22:21:37
合計ジャッジ時間 13,483 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,136 KB
testcase_01 AC 16 ms
7,896 KB
testcase_02 AC 16 ms
7,820 KB
testcase_03 AC 22 ms
7,908 KB
testcase_04 AC 516 ms
8,504 KB
testcase_05 AC 88 ms
8,192 KB
testcase_06 AC 579 ms
8,736 KB
testcase_07 AC 243 ms
8,852 KB
testcase_08 AC 829 ms
8,760 KB
testcase_09 AC 1,343 ms
9,388 KB
testcase_10 AC 343 ms
9,132 KB
testcase_11 AC 621 ms
9,204 KB
testcase_12 AC 1,040 ms
9,232 KB
testcase_13 AC 69 ms
9,044 KB
testcase_14 AC 17 ms
7,800 KB
testcase_15 AC 17 ms
7,792 KB
testcase_16 AC 16 ms
7,788 KB
testcase_17 AC 16 ms
7,804 KB
testcase_18 AC 17 ms
7,900 KB
testcase_19 AC 17 ms
7,772 KB
testcase_20 AC 16 ms
7,868 KB
testcase_21 AC 16 ms
7,788 KB
testcase_22 AC 17 ms
7,800 KB
testcase_23 AC 16 ms
7,740 KB
testcase_24 AC 180 ms
8,376 KB
testcase_25 AC 770 ms
9,272 KB
testcase_26 AC 743 ms
8,664 KB
testcase_27 AC 695 ms
8,688 KB
testcase_28 AC 369 ms
8,988 KB
testcase_29 AC 26 ms
8,632 KB
testcase_30 AC 30 ms
8,792 KB
testcase_31 AC 27 ms
8,680 KB
testcase_32 AC 25 ms
8,648 KB
testcase_33 AC 34 ms
8,992 KB
testcase_34 TLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, m, vw):
    ans = 0
    vw.sort(key = lambda x: x[0], reverse = True)
    dp = [0] * (m + 1)
    for i in range(n):
        v, w = vw[i]
        for j in range(m + 1, -1, -1):
            if j + w <= m:
                if dp[j + w] < dp[j] + v:
                    dp[j + w] = dp[j] + v
                    ans = max(ans, v * dp[j + w])
    return ans

n, m = map(int,input().split())

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

print(solve(n, m, vw))
0