Define = true if some subset of numbers can sum to exactly , false otherwise. Your target is . Base case: . An empty subset sums to 0. All other s start as false. Transition: for each number , update for all valid .
If you could reach before, you can reach by adding . Process sums in decreasing order to avoid using the same number twice.