Subfield: Combinatorics


Question: The $n$ contestants of an EGMO are named $C_{1}, \ldots, C_{n}$. After the competition they queue in front of the restaurant according to the following rules.

- The Jury chooses the initial order of the contestants in the queue.
- Every minute, the Jury chooses an integer $i$ with $1 \leq i \leq n$.
    - If contestant $C_{i}$ has at least $i$ other contestants in front of her, she pays one euro to the Jury and moves forward in the queue by exactly $i$ positions.
    - If contestant $C_{i}$ has fewer than $i$ other contestants in front of her, the restaurant opens and the process ends.
Prove that the process cannot continue indefinitely, regardless of the Jury's choices.

Solution:
To begin with, we show that it is possible for the Jury to collect this number of euros. We argue by induction. Let us assume that the Jury can collect $M_{n}$ euros in a configuration with $n$ contestants. Then we show that the Jury can collect at least $2 M_{n}+n$ moves in a configuration with $n+1$ contestants. Indeed, let us begin with all the contestants lined up in reverse order. In the first $M_{n}$ moves the Jury keeps $C_{n+1}$ in first position and reverses the order of the remaining contestants, then in the next $n$ moves all contestants $C_{1}, \ldots, C_{n}$ (in this order) jump over $C_{n+1}$ and end up in the first $n$ positions of the line in reverse order, and finally in the last $M_{n}$ moves the Jury rearranges the first $n$ positions.

Since $M_{1}=0$ and $M_{n+1} \geq 2 M_{n}+n$, an easy induction shows that $M_{n} \geq 2^{n}-n-1$.

<img_3565>

Let us show now that at most $2^{n}-n-1$ moves are possible. To this end, let us identify a line of contestants with a permutation $\sigma$ of $\{1, \ldots, n\}$. To each permutation we associate the set of reverse pairs

$$
R(\sigma):=\{(i, j): 1 \leq i<j \leq n \text { and } \sigma(i)>\sigma(j)\}
$$

and the nonnegative integer

$$
W(\sigma):=\sum_{(i, j) \in R(\sigma)} 2^{i}
$$

which we call the total weight of the permutation. We claim that the total weight decreases after any move of the contestants. Indeed, let us assume that $C_{i}$ moves forward in the queue, let $\sigma$ be the permutation before the move, and let $\sigma^{\prime}$ denote the permutation after the move. Since $C_{i}$ jumps over exactly $i$ contestants, necessarily she jumps over at least one contestant $C_{j}$ with index



$j>i$. This means that the pair $(i, j)$ is reverse with respect to $\sigma$ but not with respect to $\sigma^{\prime}$, and this yields a reduction of $2^{i}$ in the total weight. On the other hand, the move by $C_{i}$ can create new reverse pairs of the form $(k, i)$ with $k<i$, but their total contribution is at most

$$
2^{0}+2^{1}+\ldots+2^{i-1}=2^{i}-1
$$

In conclusion, when passing from $\sigma$ to $\sigma^{\prime}$, at least one term $2^{i}$ disappears from the computation of the total weight, and the sum of all the new terms that might have been created is at most $2^{i}-1$. This shows that $W\left(\sigma^{\prime}\right) \leq W(\sigma)-1$.
the previous solution, the fundamental observation is again that, when a contestant $C_{i}$ moves forward, necessarily she has to jump over at least one contestant $C_{j}$ with $j>i$.

Let us show now that the process ends after a finite number of moves. Let us assume that this is not the case. Then at least one contestant moves infinitely many times. Let $i_{0}$ be the largest index such that $C_{i_{0}}$ moves infinitely many times. Then necessarily $C_{i_{0}}$ jumps infinitely many times over some fixed $C_{j_{0}}$ with $j_{0}>i_{0}$. On the other hand, we know that $C_{j_{0}}$ makes only a finite number of moves, and therefore she can precede $C_{i_{0}}$ in the line only a finite number of times, which is absurd.

In order to estimate from above the maximal number of moves, we show that the contestant $C_{i}$ can make at most $2^{n-i}-1$ moves. Indeed, let us argue by "backward extended induction". To begin with, we observe that the estimate is trivially true for $C_{n}$ because she has no legal move.

Let us assume now that the estimate has been proved for $C_{i}, C_{i+1}, \ldots, C_{n}$, and let us prove it for $C_{i-1}$. When $C_{i-1}$ moves, at least one contestant $C_{j}$ with $j>i-1$ must precede her in the line. The initial configuration can provide at most $n-i$ contestants with larger index in front of $C_{i-1}$, which means at most $n-i$ moves for $C_{i-1}$. All other moves are possible only if some contestant in the range $C_{i}, C_{i+1}, \ldots, C_{n}$ jumps over $C_{i-1}$ during her moves. As a consequence, the total number of moves of $C_{i-1}$ is at most

$$
n-i+\sum_{k=i}^{n}\left(2^{n-k}-1\right)=2^{n-i+1}-1
$$

Summing over all indices we obtain that

$$
\sum_{i=1}^{n}\left(2^{n-i}-1\right)=2^{n}-n-1
$$

which gives an estimate for the total number of moves.


Comment In every move of the example, the moving contestant jumps over exactly one contestant with larger index (and as a consequence over all contestants with smaller index).