Walking Down The Road

Limits: 1s, 256 MB

There is an M meter long road with the leftmost point of the road being the 0 meter point and the right most point being the M meter point. N people are standing at different points on the road. Akina is a great problem solver. He likes to solve problems that are related to real life. Akina is thinking if the N peoples wanted to meet at certain point and they will just walk straight to that point from their position. If X is point where they can meet such that the summation of the distances each has to walk is minimum is called “Fuchka” point. Suppose a point can contain infinitely many people. You are given a similar problem. Suppose you have to say a random point between 0 to M. What is the probability of the random point being the “Fuchka” point?

This is a companion discussion topic for the original entry at https://toph.co/p/walking-down-the-road

Probably the data set contains odd value of n. where it should be even according to the statement. Finding median by arr[n/2]-arr[(n-1)/2] fails in 0 based index where arr[n/2]-arr[n/2-1] passes. 1st one can fail only if the value of n is odd.