Almost 0

Consider a 2017 × 2017 2017 \times 2017 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 2 \times 2 square grid is exactly 0.

Let S S be the sum of all of these real numbers. What is the maximum value of S S ?

Note : Below is a 3 × 3 3 \times 3 grid which satisfies the requirements above (although its sum is not necessarily maximized).

0.3 0.2 0.6 0.4 0.3 0.7 0.5 0.6 0.2 \Large \begin{array}{|c|c|c|} \hline -0.3 & 0.2 & -0.6 \\ \hline 0.4 & -0.3 & 0.7 \\ \hline 0.5 & -0.6 & 0.2 \\ \hline \end{array}


The answer is 2017.

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.

7 solutions

Boi (보이)
Jul 23, 2017

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 7\times7 grid.


I'm going to make a "staircase" from two opposing vertices of the grid, like above.

Let each region PINK \text{PINK} and GREEN . \text{GREEN}.

It's clear that both the shaded region have the sum of 0. 0.

PINK + GREEN = 0. \text{PINK}+\text{GREEN}=0.

But then as the image above shows, if we add PINK \text{PINK} and GREEN , \text{GREEN}, we are adding the ORANGE \text{ORANGE} region twice, and never adding the WHITE \text{WHITE} region.

Then we can say that

S = PINK + GREEN ORANGE + WHITE = WHITE ORANGE \begin{aligned} S &=\text{PINK}+\text{GREEN}-\text{ORANGE}+\text{WHITE} \\ &=\text{WHITE}-\text{ORANGE} \end{aligned}

Also know that there are always one more room for WHITE \text{WHITE} than for ORANGE , \text{ORANGE},

and that WHITE \text{WHITE} and ORANGE \text{ORANGE} are, of course, independent.


Get back to the original 2017 × 2017 2017\times2017 grid.

And there are 1009 1009 rooms for WHITE \text{WHITE} , and 1008 1008 rooms for ORANGE \text{ORANGE} since there are a total of 2017 2017 rooms for WHITE \text{WHITE} and ORANGE . \text{ORANGE}.

Since the maximum of WHITE \text{WHITE} is 1009 1009 and the minimum of ORANGE \text{ORANGE} is 1008 , -1008,

it's obvious that the maximum of S S is 1009 ( 1008 ) = 2017 , 1009-(-1008)=\boxed{2017},

when all the rooms of WHITE \text{WHITE} are filled with 1 1 and all the rooms of ORANGE \text{ORANGE} are filled with 1. -1.

Which is possible, when we fill the grid like:

1 1 1 1 1 1 \cdots 1 1 1
-1 -1 -1 -1 -1 -1 \cdots -1 -1 -1
1 1 1 1 1 1 \cdots 1 1 1
\cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots
-1 -1 -1 -1 -1 -1 \cdots -1 -1 -1
1 1 1 1 1 1 \cdots 1 1 1
-1 -1 -1 -1 -1 -1 \cdots -1 -1 -1
1 1 1 1 1 1 \cdots 1 1 1
-1 -1 -1 -1 -1 -1 \cdots -1 -1 -1
1 1 1 1 1 1 \cdots 1 1 1

Note that we can also prove that S S has a minimum of 2017 , -2017, when all the rooms of WHITE \text{WHITE} are filled with 1 -1 and all the rooms of ORANGE \text{ORANGE} are filled with 1. 1.

Please comment below if I got any... grammar problems or any calculation mistakes. I'm really sleepy, so yeah.

This is really excellent!

Eli Ross Staff - 3 years, 10 months ago

Same solution!

Kelvin Hong - 3 years, 10 months ago

Log in to reply

Ayy bro nice!

Boi (보이) - 3 years, 10 months ago

I changed the solution entirely, because this method is far better than the one I initially posted.

Boi (보이) - 3 years, 10 months ago

Log in to reply

Very nicely done! Love this :)

Calvin Lin Staff - 3 years, 10 months ago

I reached the same conclusion as I was about to fall asleep as well!

Mustaf Ahmed - 3 years, 10 months ago

Log in to reply

Pfft, what a coincidence.

Boi (보이) - 3 years, 10 months ago

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...

David Green - 3 years, 10 months ago

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.

Boi (보이) - 3 years, 10 months ago

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.

David Green - 3 years, 10 months ago

Log in to reply

@David Green Mhm, yes that's how the solution goes.

And the first part proves that if S S is maximum, the ORANGE must be all -1 and WHITE must be all 1.

Boi (보이) - 3 years, 10 months ago

@David Green Yes, that part isn't exactly clear. First he proves a bound, then he proves the bound can be achieved.

Richard Desper - 3 years, 10 months ago

Super awesome!

Uros Stojkovic - 3 years, 10 months ago

"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.

Richard Desper - 3 years, 10 months ago
Arjen Vreugdenhil
Jul 25, 2017

Number the entries in the grid a ( 0 , 0 ) a(0,0) through a ( N , N ) a(N,N) . (Here, N = 2016 N = 2016 .)

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 ) . 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 ) , a(x,y) = (-1)^{x+y}(b(x) + c(y) - d), with b ( 0 ) = c ( 0 ) = d b(0) = c(0) = d and b ( x ) , c ( y ) , d 1 |b(x)|, |c(y)|, |d| \leq 1 . These are the 2 N + 1 2N+1 degrees of freedom of the system. The constraint is b ( x ) + c ( y ) d 1. |b(x) + c(y) - d| \leq 1. Let N = 2 n + 1 N = 2n + 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 . S = \sum_{x = 0}^N \sum_{y = 0}^N (-1)^{x+y} (b(x) + c(y) - d) \\ = \sum_{x = 0}^N (-1)^x b(x) + \sum_{y = 0}^N (-1)^y c(y) - d \\ = \sum_{x = 1}^N (-1)^x b(x) + \sum_{y = 1}^N (-1)^y c(y) + d. To maximize this, we wish to maximize b ( x ) b(x) for even x x and minimize it for odd x x ; and similar for y 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 . b(2i) = p, b(2i+1) = -q, c(2j) = r, c(2j+1) = -s,\ \ \ \ \ 1 \leq i,j \leq n. Of course, p , q , r , s 1 |p|,|q|,|r|,|s| \leq 1 . The goal is to maximize S = n ( p + q + r + s ) + d S = n(p + q + r + s) + d . The constraints become p + r d , r q d , s p + d , q + s + d 1. |p + r - d|, |r - q - d|, |s - p + d|, |q + s + d| \leq 1. Now p + q + r + s = ( p + r d ) + ( q + s + d ) p + r d + q + s + d 2 , p + q + r + s = (p+r-d)+(q+s+d) \leq |p+r-d| + |q+s+d| \leq 2, so that S 2 n + d N S \leq 2n + d \leq N .

I claim that equality is actually possible, so that the solution is S = N = 2017 \boxed{S = N = 2017} .

To see this, check for each \leq sign when equality attains. In order for 2 n + d = N = 2 n + 1 2n + d = N = 2n+1 , we must have d = 1 d = 1 . Since p + r d , q + s + d 1 p+r-d, q+s+d \leq 1 , their sum is only = 2 = 2 if each equals one. This, in turn, requires p = r = 1 p = r = 1 and q = s 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 \begin{array}{cccccc} 1 & s & 1 & s & \cdots & 1 \\ -s & -1 & -s & -1 & & -s \\ 1 & s & 1 & s & \cdots & 1 \\ -s & -1 & -s & -1 & & -s \\ \vdots & & \vdots & & \ddots & \vdots \\ 1 & s & 1 & s & \cdots & 1 \end{array}

The choice s = ± 1 s = \pm 1 , gives alternating constant rows or constant columns, as others have posted. With s = 0 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!

Boi (보이) - 3 years, 10 months ago

Great! Thanks for completely classifying all maximal cases. They indeed have to be alternating rows or columns.

Calvin Lin Staff - 3 years, 10 months ago

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

Brian Ford - 3 years, 10 months ago

Log in to reply

The whole point of these solutions are proving that the case would be the limiting one.

Boi (보이) - 3 years, 10 months ago
Geoff Pilling
Jul 19, 2017

First, let's show that we can obtain 2017 2017 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 2017 × 2017 2017 \times 2017 , clearly the sum would be equal to 2017 2017 .


Now, to show that 2017 2017 is the highest sum you can attain...

Let's label the entry of row m m column n n as N m , n N_{m,n} .
We have the following observations:

  1. The sum of all the boxes with m m and n n less than 2017 2017 is 0 0 . (Since all the little 2x2 sub boxes that it is made up of sum to 0 0 )
  2. The maximum that N 2017 , 2017 N_{2017,2017} can be, of course, is 1 1 .
  3. For odd integers n n and m m , we can verify that N 2017 , n + N 2017 , n + 1 + N m , 2017 + N m + 1 , 2017 = N m , n N m + 1 , n + 1 N_{2017,n} + N_{2017,n+1} + N_{m,2017} + N_{m+1,2017} = N_{m,n} - N_{m+1,n+1} . (Can you prove this?) Hence, this expression is at most 1 ( 1 ) = 2 1 - (-1) = 2 .

Thus, if we split the sum up into 1) the top left 2016 × 2016 2016 \times 2016 grid, 2) the bottom right most square, and 3) the 2017th row and 2017th column, then it can be expressed as

Sum = ( i = 1 1008 j = 1 1008 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 2017 , 2017 ) + ( i = 1 1008 ( N 2017 , 2 i 1 + N 2017 , 2 i + N 2 i 1 , 2017 + N 2 i , 2017 ) ) \text{Sum } = \left(\sum_{i=1}^{1008} \sum_{j=1}^{1008} N_{2i-1,2j-1} + N_{2i, 2j-1} + N_{2i, 2j-1} + N_{2i, 2j} \right) + \left( N_{2017,2017} \right) + \left( \sum_{i=1}^{1008} (N_{2017,2i-1}+N_{2017,2i} + N_{2i-1,2017} + N_{2i, 2017} ) \right)

0 + 1 + 2 × 1008 \leq 0 + 1 + 2 \times 1008

= 2017 = \boxed{2017}

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.

Calvin Lin Staff - 3 years, 10 months ago

Log in to reply

Would a proof somewhere along these lines work?

Let's label all the elements N m , n N_{m,n}

Then, I think it is fairly straightforward to show that for odd m m and n n , that the maximum value of N 2017 , n + N 2017 , n + 1 + N m , 2017 + N m + 1 , 2017 N_{2017,n} + N_{2017,n+1} + N_{m,2017} + N_{m+1,2017} is 2 2 . And, the maximum that N 2017 , 2017 N_{2017,2017} can be, of course, is 1 1 .

Also, the sum of all the boxes with m m and n n less than 2017 2017 is 0 0 . (Since all the little 2x2 sub boxes that it is made up of sum to 0 0 )

So, the maximum the total sum can be is:

Maximum sum = N 2017 , 2017 + i = 0 2016 ( N 2017 , i + N i , 2017 ) \text{Maximum sum } = N_{2017,2017} + \sum_{i=0}^{2016} (N_{2017,i} + N_{i,2017})

= 1 + 2016 = 1 + 2016 (Pairing the elements of the sum up 2 at a time)

= 2017 = \boxed{2017}

Does that make sense?

Geoff Pilling - 3 years, 10 months ago

Log in to reply

Ah yes, that works out. N 2017 , n + N 2017 , n + 1 + N m , 2017 + N m + 1 , 2017 = N m , n N m + 1 , n + 1 2 N_{2017,n} + N_{2017,n+1} + N_{m,2017} + N_{m+1,2017} = N_{m,n} - N_{m+1, n+1} \leq 2 .

Calvin Lin Staff - 3 years, 10 months ago

Log in to reply

@Calvin Lin Ah... Great! I've added it to my solution above! :-)

Geoff Pilling - 3 years, 10 months ago

Another observation: If a i j a_{ij} denotes the element in the ( i , j ) (i,j) th cell of the matrix, then, for a matrix of size ( 2 n + 1 ) × ( 2 n + 1 ) (2n+1)\times (2n+1) , the sum S S turns out to be i = 1 n ( 1 ) i a i i \sum_{i=1}^n (-1)^i a_{ii} (can be verified using induction). So the maximum possible sum is 2 n + 1 2n+1 .

Samrat Mukhopadhyay - 3 years, 10 months ago

Log in to reply

Indeed. That's @H.M. 유 's solution below.

Calvin Lin Staff - 3 years, 10 months ago

Log in to reply

Oh, I did not see that before. Should I delete the comment?

Samrat Mukhopadhyay - 3 years, 10 months ago
Uros Stojkovic
Jul 27, 2017

Here's the idea that opened me up the way to the solution:

Every n × n n\times n grid with even n n has sum 0 0 . That's quite obvious but very important conclusion. A n × n n\times n with odd n n looks like this (I randomly chose 7 × 7 7\times 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 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 2\times 2 grid has to be 0 0 . But, that led me to another obvious but precious thing:

Since the sum of the blue-wired 2 × 2 2\times 2 grid in the left-bottom corner must be 0 0 , then maximum sum of the three yellow squares inside it, marked x x , y y and z z , must be 1 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 ) (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 7\times 7 grid, then, consists of 2017 2017 1s and 2016 2016 0s. Hence, maximum sum is 2017 \boxed{2017} .

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.

Richard Desper - 3 years, 10 months ago

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?"

Pi Han Goh - 3 years, 10 months ago

Oh, I didn't thought about this (2n x 2n grid gives sum 0). This certainly greatly simplifies the question. Thanks for sharing.

Pi Han Goh - 3 years, 10 months ago
Rocco Davino
Jul 29, 2017

The claim is that for any ( 2 n + 1 ) × ( 2 n + 1 ) (2n + 1) \times (2n + 1) grid with n 1 n \geq 1 satisfying the conditions above, the maximum value of S S is 2 n + 1 2n + 1 . Moreover, a grid that maximizes the sum is of the form

1 0 1 \cdots 1
0 -1 0 \cdots 0
1 0 1 \cdots 1
\vdots \vdots \vdots \ddots 0
1 0 1 0 1

. We proceed by induction on n 1 n \geq 1 . For the base case, consider a 3 × 3 3 \times 3 grid of the form

x 1 x_1 x 2 x_2 x 3 x_3
x 4 x_4 x 5 x_5 x 6 x_6
x 7 x_7 x 8 x_8 x 9 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 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) + 3x_5 , or S = ( x 2 + x 4 + x 6 + x 8 + 3 x 5 ) S = -(x_2 + x_4 + x_6 + x_8 + 3x_5) . Note that x 2 + x 3 + x 5 + x 6 = 0 x_2 + x_3 + x_5 + x_6 = 0 , or x 2 + x 5 + x 6 = x 3 x_2 + x_5 + x_6 = -x_3 . Similarly, x 4 + x 5 + x 7 + x 8 = 0 x_4 + x_5 + x_7 + x_8 = 0 means x 4 + x 5 + x 8 = x 7 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 S = -(x_2 + x_4 + x_6 + x_8 + 2x_5) - x_5 = x_3 + x_7 - x_5 . Since we want to maximize, choose x 3 = 1 x_3 = 1 , x 7 = 1 x_7 = 1 , x 5 = 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 S = 3 .

For the induction hypothesis, suppose that for a ( 2 n + 1 ) × ( 2 n + 1 ) (2n + 1) \times (2n + 1) grid with n 1 n \geq 1 satisfying the conditions above, the maximum value of S S is 2 n + 1 2n + 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 2(n+1) + 1 \times 2(n+1) + 1 grid as well. Consider the grid

1 \cdots 1 x 1 , 2 n + 2 x_{1, 2n+2} x 1 , 2 n + 3 x_{1, 2n+3}
\vdots \ddots \vdots \vdots \vdots
1 \cdots 1 x 2 n + 1 , 2 n + 2 x_{2n+1, 2n+2} x 2 n + 1 , 2 n + 3 x_{2n+1, 2n+3}
x 2 n + 2 , 1 x_{2n+2, 1} \cdots x 2 n + 2 , 2 n + 1 x_{2n+2, 2n+1} x 2 n + 2 , 2 n + 2 x_{2n+2, 2n+2} x 2 n + 2 , 2 n + 3 x_{2n+2, 2n+3}
x 2 n + 3 , 1 x_{2n+3, 1} \cdots x 2 n + 3 , 2 n + 1 x_{2n+3, 2n+1} x 2 n + 3 , 2 n + 2 x_{2n+3, 2n+2} x 2 n + 3 , 2 n + 3 x_{2n+3, 2n+3}

. The 2 n + 1 × 2 n + 1 2n+1 \times 2n+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 \sum_{i = 1}^{2n+2} x_{i, 2n+2} + x_{i, 2n+3} + x_{2n+2, i} + x_{2n+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 \sum_{i = 1}^{2n+2} x_{i, 2n+2} + x_{i, 2n+3} + x_{2n+2, i} + x_{2n+3, i} - x_{2n+2, 2n+2} = -x_{2n+2, 2n+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 S^* = \sum_{i = 1}^{2n+2} x_{i, 2n+2} + x_{i, 2n+3} + x_{2n+2, i} + x_{2n+3, i} - x_{2n+2, 2n+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 S^* + x_{2n+3, 2n+3} = -x_{2n+2, 2n+2} + x_{2n+3, 2n+3} , so we choose x 2 n + 2 , 2 n + 2 = 1 x_{2n+2, 2n+2} = -1 and x 2 n + 3 , 2 n + 3 = 1 x_{2n+3, 2n+3} = 1 . Now, it follows easily that the grid is of the form

1 \cdots 1 0 1
\vdots \ddots \vdots \vdots \vdots
1 \cdots 1 0 1
0 \cdots 0 -1 0
1 \cdots 1 0 1

and S = 2 ( n + 1 ) + 1 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.

Pi Han Goh - 3 years, 10 months ago
Arnav Singh
Jul 29, 2017

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?

Pi Han Goh - 3 years, 10 months ago

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.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...