Tuesday, August 19, 2025

King's Summit

 problem

observations
There are n points: x1=(r1,c1), x2=(r2,c2),...,xn=(rn,cn). The time it takes to get from point a=(ra,ca) to point b=(rb,cb) is the chebyshev distance between a and b: ||a-b||inf. This is length of the shortest "king-walk" between a and b on a chess-board. Thus, if all the persons meet at "summit" point s=(rs,cs), then it will take max(||s-x1||inf, ||s-x2||inf, ..., ||s-xn||inf) time, i.e. the longest time to reach the summit across all persons equals the total time it takes everyone to reach the summit. 

The chebyshev distance between points a and b is the Linf norm of the difference between a and b. The Linf norm selects the maximum component: ||a-b||inf=max(|ra-rb|,|ca-cb|). Additionally, |p| = max(-p, p). Hence, the Linf norm of ||a-b||inf = max(|ra-rb|,|ca-cb|) = max(ra-rb, rb-ra, ca-cb, cb-ca).

This leads to a big max expression:
time to reach summit becomes
= max(||s-x1||inf, ||s-x2||inf, ..., ||s-xn||inf)
= max(rs - rx1, rx1 - rs, cs - cx1, cx1 - cs,
           rs - rx2, rx2 - rs, cs - cx2, cx2 - cs,
           ...
           rs - rxn, rxn - rs, cs - cxn, cxn - cs)


Assume that the components of persons' starting positions are ordered:
rsmallest ≤ rsecond_smallest ≤ ... ≤ rbiggest
csmallest ≤ csecond_smallest ≤ ... ≤ cbiggest

Then, rs - rsmallest ≥ rs - rx2 ≥ ...rs - rbiggest. Exploiting this structure for the other maximum arguments, leads to this expression for the maximum time to summit:
= max(rs - rsmallest, rbiggest - rs, cs - csmallest, cbiggest - cs).

And, the minimum of this expression in terms of s=(rs,cs) is max( ceil((rbiggest - rsmallest) / 2), ceil((cbiggest - csmallest) / 2).