I have a set of positive numbers: ${n_1,n_2,...n_k}$ s.t. $n_1>n_2>\dots >n_k$.
I want to find an array of non-negative integers $c_1,c_2,\dots,c_k$ such that
$$n_1c_1 + n_2c_2 + \dots + n_kc_k = N $$
for some given number $N$.
I have looked into Knapsack and unbounded knapsack, but they don't explicitly look to calculate the coefficients that I'm looking for, they look to maximise the value of items. I'm not sure how to solve this. The subset sum is similar, but we need subsets of multisets here.
Also, is it possible to do this in $O(n)$ time?
time complexity $O(sum * n)$ space complexity $O(sum)$ using dynamic programming where sum is the sum of all $c_k$. see this answer by Толя https://stackoverflow.com/a/18308020 Maybe one could promote that complexity result to your more general problem? - not sure.
– Franki Nov 04 '19 at 09:23