a) We shall prove that for a table m×m (m≥2) the answer is n=2m−2; in particular n=4018 for m=2010.
Denote by aij the number written in the cell (i,j) (1≤i,j≤m). Let a, b, c and d be numbers written in cells, which centers form a rectangle with the sides parallel to those of the table. Note that any move preserves the number a−b+c−d. Hence for any equilibrium table one has that
aij−akj=cik,aji−ajk=dik(1)
Therefore, such a table is determined by 2m−1 arbitrary parameters; for example, the numbers in the first row and the first column. Any such table is equilibrium. Indeed, by moves on the columns we may obtain equal numbers in the first row. It follows from (1) that the numbers in any row are equal. Then by moves on the rows we may achieve all the numbers in the table to be equal. As a consequence, for n=2m−2 we can construct an equilibrium table, containing 2m−1 numbers: 20,21,…,2n.
We shall show that this is the largest integer n, i.e. the numbers 20,21,…,22m−1 cannot be placed in an equilibrium table m×m. We shall show a more general statement.
Lemma. The integers b1,…,b2m (m≥2) can be placed in a m×m equilibrium table if and only if there exists p, 2≤p≤m, such that after a permutation of these numbers one has that
b1+⋯+bp=bm+1+⋯+bm+p(2)
Proof. Assume that such a location is possible. We shall prove (2) by induction on m. For m=2 this follows from (1) for p=2.
Suppose that our statement is true for some m−1≥2. Consider an equilibrium table m×m, containing the numbers b1,…,b2m.
If some row and some column contains each at most one of these numbers, we delete this row and this column and we get an equilibrium table (m−1)×(m−1), containing at least 2m−2 of the b's. Applying the induction after a permutation of b's the hypothesis gives (2).
Let some row contain at most one b, but none of the columns has this property. This means that every column contains exactly two b's. We delete our row and the column that contains the respective b if there is such b, or any column if there is no such b, and we get an equilibrium table (m−1)×(m−1), containing 2m−2 of the b's, and then we continue as above.
The situation is the same if some column contains at most one b, but no rows have this property.
It remains to consider the case, when any row and any column contain exactly two b's. After permutations of the rows and columns we may assume that (after a permutation of b's) aii=bi and ai,i+1=bm+i for 1≤i≤p−1, ap1=bm+p for some p∈{2,…,m}. Then
ai1+a1i−a11=bi,ai1+a1,i+1−a11=bm+i(1≤i≤p−1),ap1+a1p−a11=bp.
Hence bi−bm+i=a1i−a1,i+1 for 1≤i≤p−1 and bp−bm+p=a1p−a11. Summing up these equalities we get that
i=1∑p(bi−bm+i)=i=1∑p−1(bi−bm+i)+(bp−bm+p)=i=1∑p−1(a1i−a1,i+1)+(a1p−a11)=0
and (2) is proved.
Conversely, if (2) holds for some p∈{2,…,m} (possible not unique), we set aii=bi and ai,i+1=bm+i for 1≤i≤p−1, ap1=bm+p. If p<m, we place others b's by following: ai1=bi, a1,i=bm+i for p+1≤i≤m. Using (1) we determine consecutively the missing elements in the first row and the first column a21,a13,a31,…,a1p. It is easy to check that (1) "completes" the table to an equilibrium one. The Lemma is proved. □
Now suppose that there exists a m×m equilibrium table containing the numbers 20,21,…,22m−1. By Lemma it follows that for some 2p numbers among them the equality (2) holds. Dividing the both parts of the equality by the least term, we obtain an equality, where one term equals 1 and all others are even, a contradiction.
b) Assume that the m×m equilibrium table contains the numbers 20,21,…,22m−1,k. According to Lemma the equality (2) holds for some 2p numbers with p∈{2,…,m}. By similar to given above reasons one concludes that the number k must be involved in this equality. Assume that k=b1. Then k=(bm+1+⋯+bm+p)−(b2+⋯+bp). The maximal value of k is reach for p=m, and it is equal to
k=(2m−1+⋯+22m−2)−(20+⋯+2m−2)=22m−1−2m+1.
In particular, for m=2010 we obtain k=24019−22010+1. □