Help with explanation

prob: https://atcoder.jp/contests/abc156/tasks/abc156_c

editorial: https://img.atcoder.jp/abc156/editorial.pdf

Strictly speaking, when holding a meeting at coordinate x which can be represented as x =
R + d (d > 0) for example, the points of stamina that i-th person will spend is:
(Xi − (R + d))2 = ((R + d) − Xi)
2 = (R − Xi)
2 + d(R − Xi) + d
2
,
and since the second term of the rightmost hand side is non-negative and the third term is
positive, the points of stamina spent is strictly greater than when holding a meeting at coordinate
R. It is the same when holding a meeting at coordinate x such that x < L.

I’m not able to understand how they derived that equation among other things

hello @raghav007

once leave this expression for some time and try to think logically.

let say u have n person living at n distinct locations and u have to organise a party a some location such that total distance they need to travel is minimised then where u will organise the party?

u will try to organise somewhere closer to center right?

say u have only two person one at 0 and one at n .
where u will organise the pary ?

yeah towards the center

and in this case . . . . ?

here also in the center

right …

so through this statement they just want to say the same thing.
i,e if leftmost person is at L and righmost person is at R then u only have to care about [L…R] location rest all location are useless (take more stamina).

now just run a brute force and find answer from each location [L…R] and print which consume less stamina

thanks, so does this mean that it is not necessary to understand the equations

whatever works for you.
if u r able think logically thats fine .otherwise math and proofs are necessary

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.