Spending a target sum, preferably split equally
You have still some work to do to get correct results in all cases. Consider M=3 and prizes [2,1,4,3]. Your algorithm sorts the list, splits it in two and considers pairs where one item is from the left half and the other from the right. You will not find the sum 1+2 because both numbers will be in the left half.