Consider a 2 0 1 7 × 2 0 1 7 square grid. Each cell is filled in with a real number with absolute value at most 1, such that the sum of any 2 × 2 square grid is exactly 0.
Let S be the sum of all of these real numbers. What is the maximum value of S ?
Note : Below is a 3 × 3 grid which satisfies the requirements above (although its sum is not necessarily maximized).
− 0 . 3 0 . 4 0 . 5 0 . 2 − 0 . 3 − 0 . 6 − 0 . 6 0 . 7 0 . 2
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This is really excellent!
Same solution!
I changed the solution entirely, because this method is far better than the one I initially posted.
I reached the same conclusion as I was about to fall asleep as well!
I think there's an assumption that we are able to fill all WHITE with -1 and ORANGE with 1. How do we know we're able to do that? Perhaps if we do that it's impossible to make the rest of the grid work as per the restriction...
Log in to reply
We can. It's as easy as just flipping the 1's and -1's in the example grid I've shown in my solution.
Log in to reply
Oh I see so the first part of the proof proves that the solution is at most 2017 and then the example proves that this is achievable.
Log in to reply
@David Green – Mhm, yes that's how the solution goes.
And the first part proves that if S is maximum, the ORANGE must be all -1 and WHITE must be all 1.
@David Green – Yes, that part isn't exactly clear. First he proves a bound, then he proves the bound can be achieved.
Super awesome!
"and that WHITE and ORANGE are independent".
Well, they're not independent, but it doesn't matter. There is a diagonal filled with 2x2 squares that include one white and one orange square each. The first part of the solution is only to prove a bound, so independence is irrelevant.
Number the entries in the grid a ( 0 , 0 ) through a ( N , N ) . (Here, N = 2 0 1 6 .)
It is easy to prove by induction that a ( x , y ) = ( − 1 ) y a ( x , 0 ) + ( − 1 ) x a ( 0 , y ) − ( − 1 ) x + y a ( 0 , 0 ) . This may also be written as a ( x , y ) = ( − 1 ) x + y ( b ( x ) + c ( y ) − d ) , with b ( 0 ) = c ( 0 ) = d and ∣ b ( x ) ∣ , ∣ c ( y ) ∣ , ∣ d ∣ ≤ 1 . These are the 2 N + 1 degrees of freedom of the system. The constraint is ∣ b ( x ) + c ( y ) − d ∣ ≤ 1 . Let N = 2 n + 1 . Then the sum is S = x = 0 ∑ N y = 0 ∑ N ( − 1 ) x + y ( b ( x ) + c ( y ) − d ) = x = 0 ∑ N ( − 1 ) x b ( x ) + y = 0 ∑ N ( − 1 ) y c ( y ) − d = x = 1 ∑ N ( − 1 ) x b ( x ) + y = 1 ∑ N ( − 1 ) y c ( y ) + d . To maximize this, we wish to maximize b ( x ) for even x and minimize it for odd x ; and similar for y . Without loss of generality we can make a regular pattern with b ( 2 i ) = p , b ( 2 i + 1 ) = − q , c ( 2 j ) = r , c ( 2 j + 1 ) = − s , 1 ≤ i , j ≤ n . Of course, ∣ p ∣ , ∣ q ∣ , ∣ r ∣ , ∣ s ∣ ≤ 1 . The goal is to maximize S = n ( p + q + r + s ) + d . The constraints become ∣ p + r − d ∣ , ∣ r − q − d ∣ , ∣ s − p + d ∣ , ∣ q + s + d ∣ ≤ 1 . Now p + q + r + s = ( p + r − d ) + ( q + s + d ) ≤ ∣ p + r − d ∣ + ∣ q + s + d ∣ ≤ 2 , so that S ≤ 2 n + d ≤ N .
I claim that equality is actually possible, so that the solution is S = N = 2 0 1 7 .
To see this, check for each ≤ sign when equality attains. In order for 2 n + d = N = 2 n + 1 , we must have d = 1 . Since p + r − d , q + s + d ≤ 1 , their sum is only = 2 if each equals one. This, in turn, requires p = r = 1 and q = − s . When these conditions are fulfilled, we actually attain the maximum value.
What does this pattern look like?
1 − s 1 − s ⋮ 1 s − 1 s − 1 s 1 − s 1 − s ⋮ 1 s − 1 s − 1 s ⋯ ⋯ ⋱ ⋯ 1 − s 1 − s ⋮ 1
The choice s = ± 1 , gives alternating constant rows or constant columns, as others have posted. With s = 0 we get a solution in which half of the numbers in the grid is zero.
Yea that's what my pattern looks like too!
Great! Thanks for completely classifying all maximal cases. They indeed have to be alternating rows or columns.
I've just signed on to this web-site, so it is new to me.
My logic for this was that one could have each odd numbered row be filled with + 1 and every even numbered be filled with -1. That would be the limiting case.
And if that were the case, then there would be 1009 rows of 2017 boxes filled with positive one
and 1008 rows of boxes filled with negative 1. So, yes 2017
(1009 x 2017 x 1) + (1008 x 2017 x -1)
= (1009 x 2017 x 1) - (1008 x 2017 x 1)
= (1009 - 1008) (2017 x 1)
= 1 x 2017 = 2017
Log in to reply
The whole point of these solutions are proving that the case would be the limiting one.
First, let's show that we can obtain 2 0 1 7 for the sum...
Fill the first row with one's and fill every other row after that alternatively with -1's and 1's. For example for a 5x5 this would look like this:
1 | 1 | 1 | 1 | 1 |
-1 | -1 | -1 | -1 | -1 |
1 | 1 | 1 | 1 | 1 |
-1 | -1 | -1 | -1 | -1 |
1 | 1 | 1 | 1 | 1 |
If we extended this to 2 0 1 7 × 2 0 1 7 , clearly the sum would be equal to 2 0 1 7 .
Now, to show that 2 0 1 7 is the highest sum you can attain...
Let's label the entry of row
m
column
n
as
N
m
,
n
.
We have the following observations:
Thus, if we split the sum up into 1) the top left 2 0 1 6 × 2 0 1 6 grid, 2) the bottom right most square, and 3) the 2017th row and 2017th column, then it can be expressed as
Sum = ( i = 1 ∑ 1 0 0 8 j = 1 ∑ 1 0 0 8 N 2 i − 1 , 2 j − 1 + N 2 i , 2 j − 1 + N 2 i , 2 j − 1 + N 2 i , 2 j ) + ( N 2 0 1 7 , 2 0 1 7 ) + ( i = 1 ∑ 1 0 0 8 ( N 2 0 1 7 , 2 i − 1 + N 2 0 1 7 , 2 i + N 2 i − 1 , 2 0 1 7 + N 2 i , 2 0 1 7 ) )
≤ 0 + 1 + 2 × 1 0 0 8
= 2 0 1 7
Hm, this problem turned out to be a lot harder than I expected it. My initial proof is wrong, and I'm not certain if I have the correct answer.
Log in to reply
Would a proof somewhere along these lines work?
Let's label all the elements N m , n
Then, I think it is fairly straightforward to show that for odd m and n , that the maximum value of N 2 0 1 7 , n + N 2 0 1 7 , n + 1 + N m , 2 0 1 7 + N m + 1 , 2 0 1 7 is 2 . And, the maximum that N 2 0 1 7 , 2 0 1 7 can be, of course, is 1 .
Also, the sum of all the boxes with m and n less than 2 0 1 7 is 0 . (Since all the little 2x2 sub boxes that it is made up of sum to 0 )
So, the maximum the total sum can be is:
Maximum sum = N 2 0 1 7 , 2 0 1 7 + i = 0 ∑ 2 0 1 6 ( N 2 0 1 7 , i + N i , 2 0 1 7 )
= 1 + 2 0 1 6 (Pairing the elements of the sum up 2 at a time)
= 2 0 1 7
Does that make sense?
Log in to reply
Ah yes, that works out. N 2 0 1 7 , n + N 2 0 1 7 , n + 1 + N m , 2 0 1 7 + N m + 1 , 2 0 1 7 = N m , n − N m + 1 , n + 1 ≤ 2 .
Log in to reply
@Calvin Lin – Ah... Great! I've added it to my solution above! :-)
Another observation: If a i j denotes the element in the ( i , j ) th cell of the matrix, then, for a matrix of size ( 2 n + 1 ) × ( 2 n + 1 ) , the sum S turns out to be ∑ i = 1 n ( − 1 ) i a i i (can be verified using induction). So the maximum possible sum is 2 n + 1 .
Log in to reply
Indeed. That's @H.M. 유 's solution below.
Log in to reply
Oh, I did not see that before. Should I delete the comment?
Here's the idea that opened me up the way to the solution:
Every n × n grid with even n has sum 0 . That's quite obvious but very important conclusion. A n × n with odd n looks like this (I randomly chose 7 × 7 grid):
and it sum comes down to the sum of yellow squares because pink part is actually an even-n grid which, we know, sums to 0 .
When I saw that, I said to myself: Hey, can I put 1 in each yellow square?
I immediately realized that it will be imposible since it won't satisfy the rule that the sum of every 2 × 2 grid has to be 0 . But, that led me to another obvious but precious thing:
Since the sum of the blue-wired 2 × 2 grid in the left-bottom corner must be 0 , then maximum sum of the three yellow squares inside it, marked x , y and z , must be 1 . Also, it seems logical that, in order to maximize the sum of the yellow part, we should fill it with greatest possible values that would fit.
Now, trying out by plugging in some values, we see that when we set ( x , y , z ) = ( 0 , 1 , 0 ) and complete the rest of the grid by following the rules, we get maximum sum for the yellow part as well as for the whole grid. Yellow part of the 7 × 7 grid, then, consists of 2 0 1 7 1s and 2 0 1 6 0s. Hence, maximum sum is 2 0 1 7 .
P.S. There are other possible ways to fill the grid, like @Arjen Vreugdenhil , @Geoff Pilling and @H.M. 유 showed.
You haven't really shown that alternating 0s and 1s provides a maximal solution. You haven't shown either that such a pattern could be part of a possible solution or that it would be maximal.
Log in to reply
Oh wait, did the question asked for the maximum value?
EDIT: Oh dang it, I somehow read it as "Can 2017 be achieved?"
Oh, I didn't thought about this (2n x 2n grid gives sum 0). This certainly greatly simplifies the question. Thanks for sharing.
The claim is that for any ( 2 n + 1 ) × ( 2 n + 1 ) grid with n ≥ 1 satisfying the conditions above, the maximum value of S is 2 n + 1 . Moreover, a grid that maximizes the sum is of the form
1 | 0 | 1 | ⋯ | 1 |
0 | -1 | 0 | ⋯ | 0 |
1 | 0 | 1 | ⋯ | 1 |
⋮ | ⋮ | ⋮ | ⋱ | 0 |
1 | 0 | 1 | 0 | 1 |
. We proceed by induction on n ≥ 1 . For the base case, consider a 3 × 3 grid of the form
x 1 | x 2 | x 3 |
x 4 | x 5 | x 6 |
x 7 | x 8 | x 9 |
. Using the assumptions, we can write 0 = ( x 1 + x 2 + x 3 + x 4 + x 5 + x 6 + x 7 + x 8 + x 9 ) + ( x 2 + x 4 + x 6 + x 8 ) + 3 x 5 , or S = − ( x 2 + x 4 + x 6 + x 8 + 3 x 5 ) . Note that x 2 + x 3 + x 5 + x 6 = 0 , or x 2 + x 5 + x 6 = − x 3 . Similarly, x 4 + x 5 + x 7 + x 8 = 0 means x 4 + x 5 + x 8 = − x 7 . Then it follows that S = − ( x 2 + x 4 + x 6 + x 8 + 2 x 5 ) − x 5 = x 3 + x 7 − x 5 . Since we want to maximize, choose x 3 = 1 , x 7 = 1 , x 5 = − 1 . These choices force us to create the grid
1 | 0 | 1 |
0 | -1 | 0 |
1 | 0 | 1 |
and we get S = 3 .
For the induction hypothesis, suppose that for a ( 2 n + 1 ) × ( 2 n + 1 ) grid with n ≥ 1 satisfying the conditions above, the maximum value of S is 2 n + 1 , and that the grid is of the desired form. We want to show that this is true for the 2 ( n + 1 ) + 1 × 2 ( n + 1 ) + 1 grid as well. Consider the grid
1 | ⋯ | 1 | x 1 , 2 n + 2 | x 1 , 2 n + 3 |
⋮ | ⋱ | ⋮ | ⋮ | ⋮ |
1 | ⋯ | 1 | x 2 n + 1 , 2 n + 2 | x 2 n + 1 , 2 n + 3 |
x 2 n + 2 , 1 | ⋯ | x 2 n + 2 , 2 n + 1 | x 2 n + 2 , 2 n + 2 | x 2 n + 2 , 2 n + 3 |
x 2 n + 3 , 1 | ⋯ | x 2 n + 3 , 2 n + 1 | x 2 n + 3 , 2 n + 2 | x 2 n + 3 , 2 n + 3 |
. The 2 n + 1 × 2 n + 1 grid is maximized by the induction hypothesis; it is not hard to see that ∑ i = 1 2 n + 2 x i , 2 n + 2 + x i , 2 n + 3 + x 2 n + 2 , i + x 2 n + 3 , i = 0 , which implies that ∑ i = 1 2 n + 2 x i , 2 n + 2 + x i , 2 n + 3 + x 2 n + 2 , i + x 2 n + 3 , i − x 2 n + 2 , 2 n + 2 = − x 2 n + 2 , 2 n + 2 . Let S ∗ = ∑ i = 1 2 n + 2 x i , 2 n + 2 + x i , 2 n + 3 + x 2 n + 2 , i + x 2 n + 3 , i − x 2 n + 2 , 2 n + 2 ; we note that we are trying to maximize S ∗ + x 2 n + 3 , 2 n + 3 = − x 2 n + 2 , 2 n + 2 + x 2 n + 3 , 2 n + 3 , so we choose x 2 n + 2 , 2 n + 2 = − 1 and x 2 n + 3 , 2 n + 3 = 1 . Now, it follows easily that the grid is of the form
1 | ⋯ | 1 | 0 | 1 |
⋮ | ⋱ | ⋮ | ⋮ | ⋮ |
1 | ⋯ | 1 | 0 | 1 |
0 | ⋯ | 0 | -1 | 0 |
1 | ⋯ | 1 | 0 | 1 |
and S = 2 ( n + 1 ) + 1 .
Oh wow I totally understood this solution in one glance (as compared to the others). I didn't thought about proving it via induction starting with n=3.
Sum of all cells of the grid = sum of diagonals cells, hence for 2017 grid it is 2017
How do you know that 2017 is achievable? Or better yet, how do you know that 2017 is the upper bound?
Obiously, any 2n*2n grid has a resulting S of "0". So maximum S value for a 2n+1 grid is achieved by adding 2n+1 "1's". Alternating columns of "1's" and "-1's" results in a maximun value for S of 2017.
Problem Loading...
Note Loading...
Set Loading...
I was just about to get to sleep when this idea struck through my head.
I'll give you an example with... erm, let's say, 7 × 7 grid.
I'm going to make a "staircase" from two opposing vertices of the grid, like above.
Let each region PINK and GREEN .
It's clear that both the shaded region have the sum of 0 .
PINK + GREEN = 0 .
But then as the image above shows, if we add PINK and GREEN , we are adding the ORANGE region twice, and never adding the WHITE region.
Then we can say that
S = PINK + GREEN − ORANGE + WHITE = WHITE − ORANGE
Also know that there are always one more room for WHITE than for ORANGE ,
and that WHITE and ORANGE are, of course, independent.
Get back to the original 2 0 1 7 × 2 0 1 7 grid.
And there are 1 0 0 9 rooms for WHITE , and 1 0 0 8 rooms for ORANGE since there are a total of 2 0 1 7 rooms for WHITE and ORANGE .
Since the maximum of WHITE is 1 0 0 9 and the minimum of ORANGE is − 1 0 0 8 ,
it's obvious that the maximum of S is 1 0 0 9 − ( − 1 0 0 8 ) = 2 0 1 7 ,
when all the rooms of WHITE are filled with 1 and all the rooms of ORANGE are filled with − 1 .
Which is possible, when we fill the grid like:
Note that we can also prove that S has a minimum of − 2 0 1 7 , when all the rooms of WHITE are filled with − 1 and all the rooms of ORANGE are filled with 1 .
Please comment below if I got any... grammar problems or any calculation mistakes. I'm really sleepy, so yeah.