The problem link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=13&problem=1063&mosmsg=Submission+received+with+ID+8403907
I use “maxflow and bsearch” to solve this problem ,but I get the wrong. I don't know where is worng in my code. I need you help me. Thank you very much.








I've solved this problem using binary search on answer and maximum matching algorithm (Kuhn algorithm) for checking if it possible to create perfect matching with this time.
I think you probably have error with checking line from point x on the bottom with point on top of some mountain corresponding to the condition - (obviously, no part of the path that he follows can be OVER the mountain - they can't fly).
According to statement:
"For every person i, he is planing to go left/right to some place (x,0) (where x is an integer).
then climb directly to the destination along a straight line."
It means that any person can move to any integer (x, 0) and then go directly to the top of chosen mountain along a straight line. And on this line there should be no point over the surface of mountain.