結果

問題 No.1858 Gorgeous Knapsack
ユーザー ShirotsumeShirotsume
提出日時 2022-02-03 17:14:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 421,668 KB
最終ジャッジ日時 2023-09-17 22:21:26
合計ジャッジ時間 21,310 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
29,628 KB
testcase_01 AC 131 ms
29,672 KB
testcase_02 AC 129 ms
29,548 KB
testcase_03 WA -
testcase_04 AC 449 ms
104,820 KB
testcase_05 WA -
testcase_06 AC 532 ms
121,608 KB
testcase_07 WA -
testcase_08 AC 706 ms
162,340 KB
testcase_09 AC 1,153 ms
258,336 KB
testcase_10 AC 436 ms
87,712 KB
testcase_11 AC 618 ms
133,972 KB
testcase_12 AC 920 ms
207,112 KB
testcase_13 AC 240 ms
39,904 KB
testcase_14 AC 131 ms
29,724 KB
testcase_15 AC 131 ms
29,692 KB
testcase_16 AC 131 ms
29,760 KB
testcase_17 AC 137 ms
29,796 KB
testcase_18 AC 129 ms
29,700 KB
testcase_19 AC 127 ms
29,704 KB
testcase_20 AC 128 ms
29,660 KB
testcase_21 AC 129 ms
29,740 KB
testcase_22 AC 128 ms
29,676 KB
testcase_23 AC 127 ms
29,716 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 163 ms
30,704 KB
testcase_30 AC 179 ms
30,944 KB
testcase_31 AC 174 ms
30,808 KB
testcase_32 AC 164 ms
30,456 KB
testcase_33 AC 203 ms
31,272 KB
testcase_34 AC 1,787 ms
421,668 KB
testcase_35 AC 1,787 ms
421,252 KB
testcase_36 AC 1,800 ms
421,588 KB
testcase_37 AC 130 ms
29,560 KB
testcase_38 AC 148 ms
31,044 KB
testcase_39 AC 128 ms
29,784 KB
testcase_40 AC 1,772 ms
421,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

def solve(n, m, vw):
    ans = 0
    vw.sort(key = lambda x: x[0], reverse = True)
    dp = np.array([[int(0)] * (m + 1) for _ in range(n + 1)])
    for i in range(n):
        v, w = vw[i]
        if w > m: continue
        dp[i + 1][0:w] = dp[i][0:w]
        dp[i + 1][w:] = np.maximum(dp[i][w:], dp[i][0:m + 1 - w] + v)
        ans = max(ans, int(np.max(dp[i + 1])) * int(v))
    return ans

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

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

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