u11 update
This commit is contained in:
parent
abd51544a8
commit
f4204fe698
@ -31,15 +31,20 @@ def maximum_value_with_items(maximum_weight, items):
|
||||
v = item["value"]
|
||||
Novystav = dict(stav)
|
||||
|
||||
for currW,(currV, vibir) in stav.items():
|
||||
NEwW = currW + w
|
||||
if NEwW <= maximum_weight:
|
||||
NewV = currV + v
|
||||
if NewV > Novystav.get(NEwW, (0, []))[0]:
|
||||
Novystav[NEwW] = (NewV, vibir + [item])
|
||||
|
||||
stav = Novystav
|
||||
for item in items:
|
||||
w = item["weight"]
|
||||
v = item["value"]
|
||||
Novystav = dict(stav)
|
||||
|
||||
for currW, (currV, vibir) in stav.items():
|
||||
NEwW = currW + w
|
||||
if NEwW <= maximum_weight:
|
||||
NewV = currV + v
|
||||
if NewV > Novystav.get(NEwW, (0, []))[0]:
|
||||
Novystav[NEwW] = (NewV, vibir + [item])
|
||||
|
||||
stav = Novystav
|
||||
|
||||
BV = 0
|
||||
Bvibir = []
|
||||
for v, vibir in stav.values():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user