5. In each cell of a $10 \times 10$ table, a natural number was written. Then, each cell was shaded if the number written in it was less than one of its neighbors but greater than another neighbor. (Two numbers are called neighbors if they are in cells sharing a common side.) As a result, only two cells remained unshaded. What is the minimum possible sum of the numbers in these two cells?
Solution. Answer: 20. This value is achieved if the unshaded cells are in opposite corners and contain the numbers 1 and 19.

Evaluation.

1) The cells that contain the minimum and maximum numbers are definitely not shaded. This means that the minimum and maximum each appear exactly once, and they are in the unshaded cells. Let their values be $m$ and $M$ respectively.
2) If a cell contains the number $n$, then the length of the path from it to the minimum cell is no more than $n-1$. Indeed, from a cell, you can move to an adjacent cell with a number at least 1 less, and no later than after $n-1$ steps, we will definitely reach the cell with the minimum number.

Similarly, this is true "from the other side": if the number in a cell is less than the maximum by $k$, then the distance from that cell to the maximum is no more than $k$ steps.

3) We will prove that there is a corner cell for which the sum of the distances to the two unshaded cells is at least 18. (We will call the distance between cells the length of the shortest path between them.)

Indeed, let $(a, b)$ and $(c, d)$ be the coordinates of the unshaded cells. The sum of the distances from the first unshaded cell to the four corner cells is $(b-1+a-1)+(b-1+10-a)+(10-b+a-1)+(10-b+10-a)=36$. The same is true for the second unshaded cell, so the sum of all 8 distances from the corner cells to the unshaded cells is 72. Therefore, the sum of the distances from the unshaded cells to some one corner is at least 18.

![](https://cdn.mathpix.com/cropped/2024_05_06_a5d1c0765161fb97ddb2g-2.jpg?height=437&width=442&top_left_y=1191&top_left_x=863)

4) Let the number in the corner cell found in point 3 be $x$. Then $M-m=(M-x)+(x-m)$ is no less than the sum of the lengths of the paths from the corner cell to the unshaded cells, which is at least 18. Since $m \geqslant 1$, then $M \geqslant 19$, from which $M+m \geqslant 20$.