14. Postman (2 p. 7-11). On the street, there are $n$ houses. Every day, the postman goes to the post office, takes letters for the residents of one house, and delivers them. Then he returns to the post office, takes letters for the residents of another house, and delivers them again. He continues this process until he has visited all the houses. Where should the post office be built so that the postman has to walk the least distance? The street can be considered a straight line segment.

a) Solve the problem for $n=5$.

b) Solve the problem for $n=6$.

c) Solve the problem for an arbitrary $n$.
# Solution.

a) Let's introduce a coordinate line, on which we will place the houses on Pushkin Street with coordinates $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ ordered in ascending order.

Let $t$ be the coordinate of the post office on the number line.

![](https://cdn.mathpix.com/cropped/2024_05_06_da1661e8d7e13dcaa0f5g-15.jpg?height=109&width=1177&top_left_y=2110&top_left_x=591)

The postman travels from the post office to each house and back, so the total distance traveled by the postman is

$$
2 S=2\left|x_{1}-t\right|+2\left|x_{2}-t\right|+2\left|x_{3}-t\right|+2\left|x_{4}-t\right|+2\left|x_{5}-t\right| \text {. }
$$

We need to minimize $2 S$, and thus $S$. Let's find $S$ for different values of $t$. Consider the function $S=S(t)$. The graph is a broken line with breakpoints at each of the points $x_{1}, x_{2}, \ldots, x_{5}$ (see the figure).

The slope of the leftmost segment is -5, and as $t$ moves to the right, the slope increases by 2 at each point $x_{i}$. Therefore, up to the point $x_{3}$

![](https://cdn.mathpix.com/cropped/2024_05_06_da1661e8d7e13dcaa0f5g-16.jpg?height=529&width=817&top_left_y=358&top_left_x=1088)
the function $S=S(t)$ is decreasing, and after this point, it is increasing (the scale on the y-axis is reduced for convenience).

Thus, the minimum value is achieved at the point $t=x_{3}$. The post office should be built at this point.

b) Reasoning similarly, we find that the post office should be built at $x_{3}$ or $x_{4}$ or anywhere between these points. Construct the graph scheme yourself.

c) For an arbitrary $n$, using the same reasoning, we find that $t$ should be the median of the set of numbers $x_{1}, x_{2}, \ldots, x_{n}$. That is, for odd $n$, we set $t=x_{\frac{n+1}{2}}$, and for even $n$, we need to take $x_{\frac{n}{2}} \leq t \leq x_{\frac{n+2}{2}}$.