alg: subset-sum (adapted from book)