This is very similar to the sums of the subset that I recently answered: Amount Algorithm
The only thing you need to do is keep track of which card was used to go from possible[i]to possible[i+n]. You can track them using the second array by calling it card_used, and then set card_used[i+n]the link / index of the map used to go from ito i+n. Then at the end you can get a list of cards used to get the amount of 15 (assuming that possible[15]is true), going back through the list card_used.
source
share