solution

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 0 Imported by: 0

README

01 背包问题

一共有 N 件物品, 第i(i从1开始)件物品的重量为w[i-1], 价值为v[i-1].
在总重量不超过背包承载上限 c 的情况下, 能够装入背包的最大价值是多少?

示例 1:

输入:c = 4, w = [1, 4, 3], v = [15, 30, 20]
输出:35
解释:容量为 4, 可选物品 1(15) + 3(20) = 35 > 4(30)

示例 2:

输入:c = 15, w = [5, 4, 7, 2, 6], v = [12, 3, 10, 3, 6]
输出:25
解释:5(12) + 7(10) + 2(3) = 25, 空余容量 1 

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL