u11 update
This commit is contained in:
parent
3203ab2ca9
commit
0aec79bef8
@ -2,7 +2,7 @@ def maximum_value(maximum_weight, items):
|
||||
if not items or maximum_weight <= 0:
|
||||
return 0
|
||||
|
||||
stav = {0, 0}
|
||||
stav = {0: 0}
|
||||
|
||||
for item in items:
|
||||
w = item["weight"]
|
||||
@ -10,7 +10,7 @@ def maximum_value(maximum_weight, items):
|
||||
Novystav = dict(stav)
|
||||
|
||||
for currW, currV in stav.items():
|
||||
NEwW = currW + W
|
||||
NEwW = currW + w
|
||||
if NEwW <= maximum_weight:
|
||||
NewV = currV + v
|
||||
if NewV > Novystav.get(NEwW, 0):
|
||||
@ -31,7 +31,7 @@ def maximum_value_with_items(maximum_weight, items):
|
||||
v = item["value"]
|
||||
Novystav = dict(stav)
|
||||
|
||||
for currW, currV in stav.items():
|
||||
for currW,(currV, vibir) in stav.items():
|
||||
NEwW = currW + W
|
||||
if NEwW <= maximum_weight:
|
||||
NewV = currV + v
|
||||
@ -40,12 +40,12 @@ def maximum_value_with_items(maximum_weight, items):
|
||||
|
||||
stav = Novystav
|
||||
|
||||
BV = 0
|
||||
Bvibir = []
|
||||
for v, vibir in stav.values():
|
||||
if v >BV:
|
||||
BV = v
|
||||
Bvibir = vibir
|
||||
BV = 0
|
||||
Bvibir = []
|
||||
for v, vibir in stav.values():
|
||||
if v >BV:
|
||||
BV = v
|
||||
Bvibir = vibir
|
||||
|
||||
return BV, Bvibir
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user