Olympiad Maths Prep

Track / Stage 6 / 216 of 400 #1216 of 2000

Problem 1216

National olympiad, first round
Combinatorics Difficulty 6.4 Find the answer

Let a1,a2,,an {{a} _ {1}}, {{a} _ {2}}, \ldots, {{a} _ {n}} be permutation of numbers 1,2,,n 1,2, \ldots, n , where n2 n \geq 2 .
Find the maximum value of the sum S(n)=a1a2+a2a3++an1an. S (n) = | {{a} _ {1}} - {{a} _ {2}} | + | {{a} _ {2}} - {{a} _ {3}} | + \cdots + | {{a} _ {n-1}} - {{a} _ {n}} |.

Official solution

1. Understanding the Problem:
We need to find the maximum value of the sum
S(n)=a1a2+a2a3++an1an S(n) = |a_1 - a_2| + |a_2 - a_3| + \cdots + |a_{n-1} - a_n|
where a1,a2,,ana_1, a_2, \ldots, a_n is a permutation of the numbers 1,2,,n1, 2, \ldots, n.

2. Analyzing the Absolute Differences:
To maximize S(n)S(n), we need to maximize each term aiai+1|a_i - a_{i+1}|. The maximum difference between any two numbers in the set {1,2,,n}\{1, 2, \ldots, n\} is n1n-1.

3. Constructing the Permutation:
Consider the permutation that alternates between the largest and smallest remaining numbers. For example, for n=4n = 4, the permutation would be 1,4,2,31, 4, 2, 3. This ensures that the differences are maximized.

4. General Pattern:
For a general nn, the permutation can be constructed as follows:
- Start with the smallest number, then the largest, then the second smallest, then the second largest, and so on.
- This can be written as 1,n,2,n1,3,n2,1, n, 2, n-1, 3, n-2, \ldots.

5. Calculating the Sum:
Let's calculate S(n)S(n) for this permutation:
- For n=4n = 4, the permutation is 1,4,2,31, 4, 2, 3:
S(4)=14+42+23=3+2+1=6 S(4) = |1 - 4| + |4 - 2| + |2 - 3| = 3 + 2 + 1 = 6
- For n=5n = 5, the permutation is 1,5,2,4,31, 5, 2, 4, 3:
S(5)=15+52+24+43=4+3+2+1=10 S(5) = |1 - 5| + |5 - 2| + |2 - 4| + |4 - 3| = 4 + 3 + 2 + 1 = 10

6. General Formula:
The sum S(n)S(n) for the optimal permutation is:
S(n)=(n1)+(n2)++1=k=1n1k=(n1)n2 S(n) = (n-1) + (n-2) + \cdots + 1 = \sum_{k=1}^{n-1} k = \frac{(n-1)n}{2}

7. Conclusion:
The maximum value of S(n)S(n) is given by:
S(n)=(n1)n2 S(n) = \frac{(n-1)n}{2}

The final answer is (n1)n2\boxed{\frac{(n-1)n}{2}}

Source: NuminaMath-1.5, licensed Apache-2.0. Statement and solution reproduced as published; topic, difficulty and ordering added by this site.