Permutation Distances

x i x_i is a permutation of { 1 , 2 , , 402 } \{ 1, 2, \ldots, 402 \} . What is the largest value of S = x 1 x 2 x 3 x 4 x 402 S = | \ldots | | |x_1 - x_2| -x_3| - x_4 | - \ldots -x_{402} | ?

Details and assumptions

| \cdot | is the absolute value function, which satisfies

x = { x x 0 x x < 0 |x| = \begin{cases} x & x \geq 0 \\ -x & x < 0 \end{cases} \\

For example, 5 = 5 , 7 = 7 | 5 | = 5, |-7| = 7 .


The answer is 401.

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.

6 solutions

Steven Kwon
May 20, 2014

Consider parity. Since the parity of x y |x-y| is the same as x + y x+y , it follows that S S must be odd. Since x y max ( x , y ) |x-y| \leq \max(x,y) for non-negative numbers, it follows that S 402 S \leq 402 . Hence, 401 is the maximum number possible.

Then, we note that n ( n 1 ) ( n 2 ) ( n 3 ) ||||n-(n-1)|-(n-2)|-(n-3)| =0. Thus we have . . . 401 400 399 . . . 2 1 402 = . . . 0 397 396 395 . . . 2 1 402 = . . . = 0 1 402 = 401 |||...||401-400|-399|-...-2|-1|-402| \\ =|||...|||0-397|-396|-395|-...-2|-1|-402|=...\\ =||0-1|-402|=401 .

So 401 is attainable, and we are done.

Justin Lim
May 20, 2014

Let A k = { 0 , 1 , , k } A_k=\{0,1,\dots ,k\} for any k k . Set some positive integer n 2 ( m o d 4 ) n\equiv 2\pmod 4 . Let s 2 = x 1 x 2 s_2=|x_1-x_2| and s i + 1 = s i x i + 1 s_{i+1}=|s_{i}-x_{i+1}| . Note that if a , b A a,b\in A , then a b A |a-b|\in A . Thus x 1 x 2 A |x_1-x_2|\in A , x 1 x 2 x 3 A ||x_1-x_2|-x_3|\in A ,... it follows by induction on the terms of S = s n S=s_n that S A S\in A . Thus S n S\le n .

We prove S n S\ne n . Suppose S = n S=n . Then { s n 1 , x n = { 0 , n } \{s_{n-1},x_n=\{0,n\} . But s n 1 s_{n-1} cannot be n n , otherwise x n = n x_n=n and { x 1 , x 2 , , x n 1 } = { 1 , 2 , , n 1 } \{x_1,x_2,\dots ,x_{n-1}\}=\{1,2,\dots ,n-1\} and thus s n 1 n 1 s_{n-1}\le n-1 , absurd. Thus s n 1 = 0 s_{n-1}=0 . Since n 1 1 ( m o d 4 ) n-1\equiv 1\pmod 4 , A n 1 A_{n-1} contains oddly many odd numbers.

Suppose x n 1 x_{n-1} is even. Then { x 1 , , x n 2 } \{x_1,\dots ,x_{n-2}\} contains oddly many odd numbers, and thus s n 2 s_{n-2} is odd. But 0 = s n 1 = s n 2 x n 1 0=s_{n-1}=|s_{n-2}-x_{n-1}| and since x n 1 x_{n-1} is even, 0 0 is odd, contradiction. The other case is analogous. Suppose x n 1 x_{n-1} is odd. Then { x 1 , , x n 2 } \{x_1,\dots ,x_{n-2}\} contains evenly many odd numbers, and thus s n 2 s_{n-2} is even. But 0 = s n 1 = s n 2 x n 1 0=s_{n-1}=|s_{n-2}-x_{n-1}| and since x n 1 x_{n-1} is odd, 0 0 is odd, contradiction again.

It follows that S n 1 S\le n-1 . We prove that this is achievable. Consider ( x 1 , x 2 , , x n ) = ( n 1 , n 2 , , 3 , 2 , 1 , n ) (x_1,x_2,\dots ,x_n)=(n-1,n-2,\dots ,3,2,1,n) . I claim it works. Note that ( k + 4 ) ( k + 3 ) ( k + 2 ) ( k + 1 ) = 0 |||(k+4)-(k+3)|-(k+2)|-(k+1)|=0 for all k k . It follows that in this case s n 2 = 0 s_{n-2}=0 (recall n 2 ( m o d 4 ) n\equiv 2\pmod 4 ), which implies s n 1 = 1 s_{n-1}=1 and S = s n = n 1 S=s_n=n-1 . Since 402 2 ( m o d 4 ) 402\equiv 2\pmod 4 , we easily find the answer to be 401 401 , as desired.

Arndt Jonasson
May 20, 2014

I use the notation s i s_i for partial results, with s 1 s_1 = x 1 x_1 . s i + 1 = s i x i + 1 s_{i+1} = |s_i-x_{i+1}| , so S = s 402 s_{402} .

y 1 y 2 |y_1-y_2| is at least 0 and at most m a x ( y 1 , y 2 ) max(y_1,y_2) , so all partial results in the evaluation of S are in [0,402]. The largest number we can possibly achieve is thus 402. This can happen if . . . x 1 x 2 . . . x 401 = 0 |...|x_1 - x_2| - ... - x_{401}| = 0 .

Consider odd and even numbers. If y 2 y_2 is even, the result of y 1 y 2 |y_1-y_2| is odd or even according to whether y 1 y_1 is odd or even. If y 2 y_2 is odd, the result of y 1 y 2 |y_1-y_2| is even or odd according to whether y 1 y_1 is odd or even. In other words, doing the operation of subtracting y 2 y_2 and taking the absolute value leaves the parity unchanged if y 2 y_2 is even and changes it if y 2 y_2 is odd. The odd numbers in the set are 1, 3, ... 401, which is 201 numbers. The final parity of S is therefore odd, and cannot be 402. It can be 401, however.

Let x 402 = 402 x_{402} = 402 , x 1 = 1 x_1 = 1 , and the other x i = 403 i x_i = 403-i . Then x 1 x 2 = 1 401 = 400 |x_1-x_2| = |1-401| = 400 . 400 400 = 0 |400-400| = 0 . 0 399 = 1 |0-399| = 1 . 1 398 = 397 |1-398| = 397 . This pattern continues, so that s 4 j + 1 = 1 s_{4j+1} = 1 for natural numbers j. S = s 401 402 S = |s_{401} - 402| . 401 is expressible as 4 j + 1 4j+1 , so s 401 = 1 s_{401} = 1 , and therefore S = 401.

Kevin Sun
May 20, 2014

I claim that 401 is the largest. Clearly, this is less than or equal to 402, and integral. By a simple parity argument, we have that this is odd, so it must be <= 401. To attain this, we need x 402 = 402 x_{402 }= 402 and . . . x 1 x 2 x 3 . . . x 401 = 1 |...|x_1-x_2|-x_3|-...-x_{401}| = 1 . Lemma: There exists a permutation x i x_i of {1,2, \cdots 4k+1 such that x 1 x 2 x 4 k + 1 = 1 |\cdots|x_1-x_2|-\cdots-x_{4k+1}| = 1 . Proof: Induction. When k = 0, this is obvious. Inductive step. Assume this is true for k = i-1. Then we can just let x 4 k 2 = 4 k + 1 x_{4k-2} = 4k+1 , x 4 k 1 = 4 k x_{4k-1} = 4k , x 4 k = 4 k 1 x_{4k} = 4k-1 , and x 4 k + 1 = 4 k 2 x_{4k+1} = 4k-2 , so x 1 x 2 x 4 k 2 x 4 k 1 x 4 k x 4 k + 1 ||||\cdots|x_1-x_2|-\cdots-x_{4k-2}|-x_{4k-1}|-x_{4k}|-x_{4k+1}| = 1 ( 4 k + 1 ) 4 k ( 4 k 1 ) ( 4 k 2 ) = ||||1-(4k+1)|-4k|-(4k-1)|-(4k-2) = 4 k 4 k ( 4 k 1 ) ( 4 k 2 ) = 4 k 1 ( 4 k 2 ) = 1 = |||4k-4k|-(4k-1)|-(4k-2)| = |4k-1-(4k-2)| = 1 . Thus 1 is attainable. This implies that 401 is attainable for the original expression, so the maximum value is 401.

黎 李
May 20, 2014

Group 2-401 as (2,3,4,5), (6,7,8,9), ……(398,399,400,401) to make 0, then |1-402|=401. By module 2 the answer is odd and is <=402.

Calvin Lin Staff
May 13, 2014

Since x y max { x , y } |x - y| \leq \max \{x,y\} , we get that S 402 S \leq 402 . Since x y |x-y| has the same parity as x + y x + y , it follows that S S has the same parity as 1 + 2 + + 401 = 1 2 ( 402 ) ( 403 ) 1 + 2 + \ldots + 401 = \frac {1}{2} (402)(403) , so S S is odd. Thus S 401 S \leq 401 .

To show that this is possible, use the permutation

x i = { 4 k + 2 i = 4 k + 1 , k < 100 4 k + 4 i = 4 k + 2 , k < 100 4 k + 5 i = 4 k + 3 , k < 100 4 k + 3 i = 4 k + 4 , k < 100 402 i = 401 1 i = 402 x_i = \begin{cases} 4k + 2 & i = 4k+1, k < 100 \\ 4k + 4 & i = 4k+2, k < 100 \\ 4k + 5 & i = 4k+3, k < 100 \\ 4k + 3 & i = 4k+4, k < 100 \\ 402 & i=401\\ 1 & i = 402 \\ \end{cases}

In this case, S = 401 S=401 , hence that is the maximum value.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...