Closest Subsequence Sum - Meet in the Middle

Split the array into two halves. Generate all 2202^{20} subset sums for each half.

1.1. Compute all sums for the first half: O(2n/2)O(2^{n/2}).

2.2. Compute all sums for the second half: O(2n/2)O(2^{n/2}).

3.3. Sort one list.

4.4. For each sum s1s_1 in the first list, binary search for goals1goal - s_1 in the second list to find the closest match.

Total time: O(2n/2n)O(2^{n/2} \cdot n).