This is extremely minor, but since I really enjoyed problem 22.17 (K Elements Closest to the Median) I thought I would mention it. Would it be possible to replace:
nth_element(A->begin(), target - 1, A->end());
with:
nth_element(A->begin(), target - 1, target);
for the even number of elements case? I think the first call would ensure the desired element is in the left half of the array.