There are $n$ houses on the street. 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 does this 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$.
a) Let's introduce a coordinate line, on which we will place houses 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_5e05e09159d75892ee01g-07.jpg?height=131&width=1455&top_left_y=2101&top_left_x=310)

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|$. We need to make $2 S$, and thus $S$, as small as possible.

Consider the function $S(t)$. The graph is a broken line, with points of inflection at each of the points $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ (see

figure).

![](https://cdn.mathpix.com/cropped/2024_05_06_5e05e09159d75892ee01g-08.jpg?height=669&width=1018&top_left_y=0&top_left_x=523)

The slope of the leftmost segment is -5, and as we move to the right, the slope increases by 2 at each point $x_{i}$. Thus, the function $S(t)$ decreases up to the point $x_{3}$ and increases after this point (on the graph, the scale on the y-axis is reduced for convenience).

Therefore, 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 at $x_{4}$, or at any point between these two points.

c) For an arbitrary $n$, using the same reasoning, we find that for odd $n$, $t=x_{\frac{n+1}{2}}$, and for even $n$, the minimum is achieved on the entire segment $\left[x_{\frac{n}{2}}, x_{\frac{n+2}{2}}\right]$.

## Answer

a) In the middle house; b) at any point on the segment between the two middle houses;

c) for odd $n$ in the middle house, for even $n$ at any point on the segment between the two middle houses.