5. (2003 US Olympiad Question) Let , for any integer sequence , define another sequence . Here represents the number of terms in sequence that are before and different from . Prove: Starting from any given sequence , after fewer than transformations, a sequence can be obtained such that .
Solution
5. Notice that the sequence obtained after the exchange also satisfies the inequality . We will call all sequences that satisfy these inequalities as bounded index sequences. Below we prove .
If , it is obviously true. Otherwise, let . The first terms are all not greater than , so they are all different from , and they are before (as shown in Table 1), so , i.e., . This shows that the sequence will stabilize after a finite number of transformations, because in the bounded index sequence, the value of the -th term does not exceed . Next,
The value of the -th term has the following properties: (i) it is an integer; (ii) it has an upper bound ; (iii) its value does not decrease during the transformation; (iv) once the value stabilizes under the transformation, it does not change.
This means that after no more than transformations, the sequence will stabilize.
Finally, we need to prove that starting from the initial bounded index sequence , after no more than transformations, a stable sequence can be obtained. We prove this by mathematical induction on .
When , the two possible sequences are and . Under the transformation, they are already stable.
Assume that any bounded index sequence becomes a stable sequence under the transformation after no more than transformations. Consider , we prove that stabilizes after no more than transformations.
Assume it requires transformations. This is only possible when , and each transformation increases the value of the -th term by exactly 1. Under the transformation, the value of the -th term is not affected by the terms after it. According to the induction hypothesis, the subsequence , stabilizes after no more than transformations. Because the -th term stabilizes at after no more than transformations, and the value of the -th term, based on the current assumption, becomes exactly after transformations. Therefore, it can be concluded that the -th term equals the value of the -th term after no more than transformations.
However, in a sequence, if two consecutive terms have the same value, they remain equal and stable. Because the value of the -th term stabilizes after no more than transformations, stabilizes after no more than transformations. This contradicts the assumption that it requires transformations. Therefore, at most transformations are needed to stabilize an -term bounded index sequence.
To prove that if for some , then the transformation will not change the value of the -th term. Consider the following two cases:
(1) If . This indicates that every term to the left of is 0. Then the first terms of are also 0, and this repeats.
(2) If , then the first terms are all different from . Because , so are all equal to . Therefore, . Another transformation will not change the value of the -th term (as shown in Table 2).