Problem:
An integer is put in each cell of an array. The difference between the integers in cells which share a side is or . Show that some integer occurs at least times.
Problem:
An integer is put in each cell of an array. The difference between the integers in cells which share a side is or . Show that some integer occurs at least times.
Solution:
Let the integers in the array be for . For any two adjacent cells (sharing a side), or .
Let be the minimum integer in the array. Consider the set of cells where the value is . Any cell adjacent to such a cell can have value or .
Let us color the array as follows: color cell black if is even, white if is odd. Consider the minimal value and the set of all cells with value .
Suppose . Then, in each row and each column, there is at most one cell with value (otherwise, two cells with value in the same row or column would force all cells between them to also have value , by the adjacency condition, contradicting minimality unless the whole row or column is ). Thus, .
Suppose . Then, there is a row and a column with no cell of value . Consider the path from a cell with value to a cell in this row or column. Along the path, the value can increase by at most at each step, so the maximum value in the array is at most .
But, more simply, consider the following: pick any cell with value . From this cell, move right steps and down steps to reach cell . The value at is at least and at most (since each step increases by at most ). Thus, the maximum difference between any two cells is at most .
Now, consider the values along the main diagonal: . Each adjacent pair differs by at most , so the values form an integer sequence where each term differs from the previous by at most . Thus, among these values, at least one value occurs at least times (by the pigeonhole principle), but we want at least times in the whole array.
Alternatively, consider the values in the array: the minimal value must occur in some row or column. If it occurs times in a row, then in that row, the values can only increase by at each step, so the values are . But since the difference between adjacent cells is at most , and the minimal value is , the only way for the value to increase is if the previous cell is and the next is .
But the key is:
Let us fix a value that appears in the array. Consider the set of all cells with value . Suppose that in every row, there is at most one cell with value . Then, the total number of cells with value is at most . Similarly for columns. But if there is a row with two cells with value , say and , then all cells between and in row must also have value , because the difference between adjacent cells is at most , and the values at the ends are equal. Thus, the sequence must be constant between and .
Therefore, for any value , the set of cells with value in any row or column forms a contiguous block. Thus, the set of cells with value forms a union of rectangles (possibly degenerate to a single cell or a line).
Now, consider the value that appears most frequently in the array. Suppose, for contradiction, that every value appears fewer than times. Then, the total number of values is at least for , which is impossible since the values are integers and the difference between adjacent cells is at most , so the range of values is at most (as above). For large , this is a contradiction.
But more simply, consider the following construction:
Let us fix a row. The values in the row form a sequence where adjacent terms differ by at most . Thus, the minimal value in the row occurs in a contiguous block. The same applies to columns.
Therefore, the value that appears most frequently must appear at least times, since otherwise, the total number of cells is , and the values cannot be spread out enough given the adjacency condition.
Thus, some integer occurs at least times.