# Problem 8. (5 points)

In an $8 \times 8$ table, some 23 cells are black, and the rest are white. In each white cell, the sum of the number of black cells on the same row and the number of black cells on the same column is written; nothing is written in the black cells. What is the maximum value that the sum of the numbers in the entire table can take?
Answer: 234

## Solution:

The number in the white cell consists of two addends: "horizontal" and "vertical". Consider the sum of all "horizontal" addends and the sum of all "vertical" addends separately across the entire table. If we maximize each of these two sums separately, the total sum will also be the largest.

Consider the sum of the "horizontal" addends. If a row contains $x_{i}$ black cells and $8-x_{i}$ white cells, then the sum of the horizontal addends in this row is $x_{i}(8-x_{i})$. Summing this sum over all rows, we get $8(x_{1}+\ldots+x_{8})-x_{1}^{2}-\ldots-x_{8}^{2}=8 \cdot 23-(x_{1}^{2}+\ldots+x_{8}^{2})$. We need to maximize this expression, i.e., minimize the sum of the squares of eight numbers whose sum is 23. As is known, the sum of the squares of numbers decreases as these numbers approach their arithmetic mean, so for integers, the minimum is achieved when seven of the eight numbers are 3, and the remaining one is 2.

Thus, we get that the smallest possible sum of "horizontal" addends is $8 \cdot 23-7 \cdot 3^{2}-2^{2}=117$. A similar estimate can be obtained for the sum of "vertical" addends, which gives us a final value of 234.

It remains to ensure that there is a coloring of the table in which both sums are maximal simultaneously, i.e., in which each column or row contains 2 or 3 shaded cells.

![](https://cdn.mathpix.com/cropped/2024_05_06_21e870cb932e699b067eg-4.jpg?height=434&width=552&top_left_y=2213&top_left_x=752)