I have 4 very large list (l1, l2, l3, l4) of components (approx 9 million items in each list). Each list item has a cost and a value.
I want to know how I can achieve the maximum combined value for an agreed combined total cost:
So, over all combinations in the 4 lists I want to know:
Max( l1[a].value + l2[b].value + l3[c].value + l4[d].value)
where
l1[a].cost + l2[b].cost + l3[c].cost + l4[d].cost <= X
X in the above is the total amount that I can spend.
I can obviously do this using a brute force method but that's going to take a long time to compute. I wondered if that was a more efficient way of doing this.
Any suggestions?