U11Try5
This commit is contained in:
parent
436a92c84a
commit
bdbb2e0a11
@ -4,11 +4,6 @@ def maximum_value(maximum_weight, items):
|
|||||||
return 0
|
return 0
|
||||||
if items == 0 or items is None or items ==[]:
|
if items == 0 or items is None or items ==[]:
|
||||||
return 0
|
return 0
|
||||||
if len(items) == 1:
|
|
||||||
curent_dic = items[0]
|
|
||||||
weight = curent_dic.get("weight")
|
|
||||||
if weight > maximum_weight:
|
|
||||||
return 0
|
|
||||||
#ділимо на лісти
|
#ділимо на лісти
|
||||||
weight = []
|
weight = []
|
||||||
value = []
|
value = []
|
||||||
@ -26,10 +21,10 @@ def maximum_value(maximum_weight, items):
|
|||||||
stav = (pocet,zostava)
|
stav = (pocet,zostava)
|
||||||
if stav in pamat:
|
if stav in pamat:
|
||||||
return pamat[stav]
|
return pamat[stav]
|
||||||
|
|
||||||
index = pocet - 1
|
index = pocet - 1
|
||||||
better = vyries(pocet - 1,zostava)
|
better = vyries(pocet - 1,zostava)
|
||||||
|
|
||||||
if weight[index] <=zostava:
|
if weight[index] <=zostava:
|
||||||
better = max(better,value[index] + vyries(pocet - 1,zostava - weight[index]))
|
better = max(better,value[index] + vyries(pocet - 1,zostava - weight[index]))
|
||||||
pamat[stav] = better
|
pamat[stav] = better
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user