Блог пользователя Rajib_119

Автор Rajib_119, история, 7 лет назад, По-английски

Need help in this problem. What is the formula? Thanks in Advance.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

The problem is simple, It requires to know the concept of median. Well the approach is: We sort all the positions. Then We Can say that the fucka point lies in the range of middle two elements.

Now the probabilty(ans) is : (length of the segment between two mid points)/m
ie after sorting ans is: (a[n/2]-a[(n-1)/2])/m;

The proof is easy to realise by writing the expression for distance and see that median always satisfy the condition.