結果

問題 No.1858 Gorgeous Knapsack
ユーザー ああいいああいい
提出日時 2022-02-28 12:56:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 78,260 KB
最終ジャッジ日時 2023-09-20 20:26:33
合計ジャッジ時間 7,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,520 KB
testcase_01 AC 71 ms
71,132 KB
testcase_02 WA -
testcase_03 AC 83 ms
75,944 KB
testcase_04 AC 158 ms
78,076 KB
testcase_05 AC 98 ms
76,768 KB
testcase_06 AC 143 ms
77,876 KB
testcase_07 AC 129 ms
77,980 KB
testcase_08 AC 173 ms
77,956 KB
testcase_09 AC 223 ms
77,996 KB
testcase_10 AC 145 ms
77,904 KB
testcase_11 AC 172 ms
78,116 KB
testcase_12 AC 195 ms
77,928 KB
testcase_13 AC 118 ms
77,832 KB
testcase_14 AC 78 ms
75,944 KB
testcase_15 AC 74 ms
71,280 KB
testcase_16 AC 79 ms
75,948 KB
testcase_17 AC 75 ms
71,228 KB
testcase_18 AC 73 ms
71,292 KB
testcase_19 AC 72 ms
71,244 KB
testcase_20 AC 73 ms
71,568 KB
testcase_21 AC 74 ms
71,216 KB
testcase_22 AC 73 ms
71,088 KB
testcase_23 AC 74 ms
71,572 KB
testcase_24 AC 104 ms
77,076 KB
testcase_25 AC 169 ms
78,076 KB
testcase_26 AC 166 ms
77,628 KB
testcase_27 AC 158 ms
77,700 KB
testcase_28 AC 140 ms
78,196 KB
testcase_29 AC 107 ms
77,724 KB
testcase_30 AC 113 ms
77,616 KB
testcase_31 AC 109 ms
77,676 KB
testcase_32 AC 113 ms
77,620 KB
testcase_33 AC 110 ms
77,684 KB
testcase_34 AC 433 ms
78,160 KB
testcase_35 AC 128 ms
77,972 KB
testcase_36 AC 405 ms
78,260 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 76 ms
75,944 KB
testcase_40 AC 126 ms
77,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
l = []
for i in range(N):
    v,w = map(int,input().split())
    l.append((v,w))
l.sort(reverse = True,key = lambda s:s[0])
#dp = [[0] * (M+1) for _ in range(N+1)]
dp = [0] * (M+1)
ans = 0
for i in range(N):
    v,w = l[i]
    nx = dp.copy()
    tmp = 0
    for j in range(M+1-w):
        if tmp < dp[j]:
            tmp = dp[j]
    if ans < (tmp + v) * v:
        ans = (tmp + v) * v
    for j in range(M+1-w):
        nx[j+w] = max(nx[j+w],dp[j] + v)
    dp = nx
print(ans)
0