結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,288 KB
testcase_01 AC 73 ms
71,192 KB
testcase_02 AC 73 ms
71,572 KB
testcase_03 AC 84 ms
76,120 KB
testcase_04 AC 163 ms
78,044 KB
testcase_05 AC 102 ms
77,124 KB
testcase_06 AC 147 ms
78,020 KB
testcase_07 AC 135 ms
77,912 KB
testcase_08 AC 182 ms
78,104 KB
testcase_09 AC 231 ms
77,948 KB
testcase_10 AC 148 ms
77,936 KB
testcase_11 AC 165 ms
78,096 KB
testcase_12 AC 207 ms
77,988 KB
testcase_13 AC 116 ms
77,516 KB
testcase_14 AC 79 ms
76,084 KB
testcase_15 AC 74 ms
71,320 KB
testcase_16 AC 78 ms
75,992 KB
testcase_17 AC 73 ms
71,248 KB
testcase_18 AC 73 ms
71,252 KB
testcase_19 AC 72 ms
71,572 KB
testcase_20 AC 73 ms
71,456 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 104 ms
76,916 KB
testcase_25 AC 169 ms
78,288 KB
testcase_26 AC 172 ms
77,952 KB
testcase_27 AC 158 ms
77,716 KB
testcase_28 AC 132 ms
78,404 KB
testcase_29 AC 109 ms
77,640 KB
testcase_30 AC 113 ms
77,716 KB
testcase_31 AC 112 ms
77,940 KB
testcase_32 AC 114 ms
77,904 KB
testcase_33 AC 113 ms
77,936 KB
testcase_34 AC 424 ms
78,028 KB
testcase_35 WA -
testcase_36 AC 403 ms
78,444 KB
testcase_37 AC 72 ms
71,448 KB
testcase_38 AC 102 ms
77,016 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = -1
    for j in range(M+1-w):
        if tmp < dp[j]:
            tmp = dp[j]
    if tmp > 0 and 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