結果

問題 No.1858 Gorgeous Knapsack
ユーザー 👑 colognecologne
提出日時 2022-02-27 13:11:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 78,488 KB
最終ジャッジ日時 2023-09-18 23:36:51
合計ジャッジ時間 6,102 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,508 KB
testcase_01 AC 68 ms
71,400 KB
testcase_02 AC 69 ms
71,432 KB
testcase_03 AC 74 ms
75,664 KB
testcase_04 AC 124 ms
77,144 KB
testcase_05 AC 85 ms
76,424 KB
testcase_06 AC 119 ms
78,052 KB
testcase_07 AC 112 ms
77,772 KB
testcase_08 AC 129 ms
78,052 KB
testcase_09 AC 145 ms
78,104 KB
testcase_10 AC 117 ms
78,108 KB
testcase_11 AC 115 ms
77,972 KB
testcase_12 AC 136 ms
78,168 KB
testcase_13 AC 108 ms
78,108 KB
testcase_14 AC 72 ms
75,600 KB
testcase_15 AC 69 ms
71,512 KB
testcase_16 AC 71 ms
75,440 KB
testcase_17 AC 68 ms
71,628 KB
testcase_18 AC 68 ms
71,396 KB
testcase_19 AC 68 ms
71,508 KB
testcase_20 AC 67 ms
71,504 KB
testcase_21 AC 67 ms
71,600 KB
testcase_22 AC 68 ms
71,396 KB
testcase_23 AC 69 ms
71,508 KB
testcase_24 AC 88 ms
76,180 KB
testcase_25 AC 122 ms
78,388 KB
testcase_26 AC 122 ms
78,068 KB
testcase_27 AC 121 ms
77,904 KB
testcase_28 AC 115 ms
78,488 KB
testcase_29 AC 102 ms
77,744 KB
testcase_30 AC 105 ms
78,152 KB
testcase_31 AC 103 ms
77,940 KB
testcase_32 AC 104 ms
77,992 KB
testcase_33 AC 107 ms
78,192 KB
testcase_34 AC 207 ms
78,232 KB
testcase_35 AC 102 ms
78,104 KB
testcase_36 AC 205 ms
78,024 KB
testcase_37 AC 67 ms
71,436 KB
testcase_38 AC 100 ms
78,072 KB
testcase_39 AC 71 ms
75,612 KB
testcase_40 AC 102 ms
78,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, M = map(int, input().split())
    vw = [list(map(int, input().split())) for i in range(N)]
    vw.sort(key=lambda x: x[0], reverse=True)

    ans = 0
    DP = [0]*(M+1)
    for v, w in vw:
        for i in range(M-w, -1, -1):
            DP[i+w] = max(DP[i+w], DP[i]+v)
        ans = max(ans, v * DP[M])

    print(ans)


if __name__ == '__main__':
    main()
0