I am trying to learn ternary search and came across a problem “plant location” at codechef.

I am really not getting how ternary search can be applied in this problem. When I read about it at wiki it talks about function with one minimum or maximum but in this problem how one can estimate that there is only one point which is optimum(i mean only one point whose sum of distance from all points is minimum)? Secondly how we can decide it is ternary search not binary search that should be used?I am really confused on this issue.

If someone can provide any links that are related to ternary search i will be really greatful.

Thanks.

Problem link: K1 Problem - CodeChef