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