u11 update
This commit is contained in:
parent
adcd3a3d0a
commit
83f2d4c807
@ -13,5 +13,19 @@ def maximum_value(maximum_weight, items):
|
||||
return TEPvalue
|
||||
|
||||
def maximum_value_with_items(maximum_weight, items):
|
||||
return 0, []
|
||||
if not items or maximum_weight <= 0
|
||||
return 0, []
|
||||
|
||||
sorteditem = sorted(items, key=lambda x: x["value"] / x["weight"], reverse=True)
|
||||
|
||||
TEPvalue = 0
|
||||
currweight = 0
|
||||
vibir = []
|
||||
for item in sorteditem:
|
||||
if currweight + item["weight"] <= maximum_weight:
|
||||
currweight += item["weight"]
|
||||
TEPvalue += item["value"]
|
||||
vibir.append(item)
|
||||
|
||||
return TEPvalue, vibir
|
||||
|
||||
Loading…
Reference in New Issue
Block a user