9.5. In each cell of a $5 \times 5$ table, one of the numbers $1,2,3,4,5$ is written in such a way that each row, each column, and each of the two diagonals of the table contains each of the numbers from 1 to 5. What is the maximum value that the sum of the five numbers written in the cells marked with dots on the diagram can take?
Answer: 22.

![](https://cdn.mathpix.com/cropped/2024_05_06_1f30a33b953311bd9a4dg-2.jpg?height=280&width=280&top_left_y=1619&top_left_x=1622)

Solution. If all 4 numbers marked with a dot and not in the top right corner are different, then the sum of all numbers marked with a dot does not exceed $5+5+4+3+2=19$. Let's further assume that among these numbers there are two equal ones, and consider three possible arrangements of their positions. Denote the columns of the table from left to right by the letters $a, b, c, d, e$, and the rows by the numbers from 1 to 5. The diagonal from corner $a 1$ to corner $e 5$ will be called the main diagonal, and the diagonal from corner $a 5$ to corner $e 1$ will be called the secondary diagonal. The pair of equal numbers will be denoted by $a$.

1) The numbers in cells $a 4$ and $d 1$ are equal. The remaining numbers equal to $a$ cannot be placed in the 1st and 4th rows and in columns $a$ and $d$, so on the secondary diagonal, $a$ can only be in cell $c 3$. The two remaining numbers $a$ can only be in cells $b 5$ and $e 2$.

![](https://cdn.mathpix.com/cropped/2024_05_06_1f30a33b953311bd9a4dg-2.jpg?height=232&width=237&top_left_y=2294&top_left_x=1635)

2) The numbers in cells $b 3$ and $c 2$ are equal. The remaining numbers equal to $a$ cannot be placed in the 2nd and 3rd rows and in columns $b$ and $c$, so on the diagonals, the number $a$ can only be in the corner cells and cell $d 4$.

![](https://cdn.mathpix.com/cropped/2024_05_06_1f30a33b953311bd9a4dg-2.jpg?height=234&width=234&top_left_y=2553&top_left_x=1668)

The corner cells cannot contain two equal numbers, as any pair of corner cells lies either in the same row, column, or diagonal, so one $a$ is in cell $d 4$. It excludes cells on the main diagonal, row 4, and column $d 4$, so the two remaining numbers $a$ can only be in cells $a 5$ and $e 1$ on the secondary diagonal, which is impossible.

3) The numbers in cells $a 4$ and $c 2$ are equal. The remaining numbers equal to $a$ cannot be placed in the 2nd and 4th rows and in columns $a$ and $c$, so on the diagonals, the numbers $a$ can only be in the corner cells $e 1$ and $e 5$. These cells lie in the same column, which is impossible.

![](https://cdn.mathpix.com/cropped/2024_05_06_1f30a33b953311bd9a4dg-3.jpg?height=240&width=220&top_left_y=494&top_left_x=1680)

4) The numbers in cells $a 4$ and $b 3$ are equal. The remaining numbers equal to $a$ cannot be placed in the 3rd and 4th rows and in columns $a$ and $b$, and on the main diagonal, the number $a$ must be in cell $e 5$. Then on the secondary diagonal, it is in cell $d 2$, and on the first row, it is in cell $c 1$.

The conducted analysis shows that three identical numbers or two pairs of equal numbers among the 4 numbers marked with a dot and not in the top right corner cannot exist because the permissible configurations of cases 1) and 4) cannot occur simultaneously. Therefore, the sum of these four numbers does not exceed $5+5+4+3=17$, and the sum of the five numbers marked with dots does not exceed $17+5=22$. The upper bound has been obtained.

Example of number placement satisfying the condition with a sum of 22:

| 3 | 4 | 1 | 2 | 5 |
| :--- | :--- | :--- | :--- | :--- |
| 5 | 1 | 3 | 4 | 2 |
| 4 | 5 | 2 | 1 | 3 |
| 2 | 3 | 4 | 5 | 1 |
| 1 | 2 | 5 | 3 | 4 |

Grading criteria. Any attempt to prove an incorrect answer: 0 points. Correct answer with an example: 3 points. Proof of the maximum sum of 22: 4 points. If the enumeration in the proof is incomplete: points are reduced proportionally.