On the complexity of k-best and 2nd-best optimization problems