There are students and classrooms in the Olympiad High School. At the beginning, each of the students is in one of the classrooms. Each minute, as long as not everyone is in the same classroom, somebody walks from one classroom into a different classroom with at least as many students in it (prior to his move). This process will terminate in minutes. Determine the maximum value of .
Problem 1972
Official solution
Solution: The answer is .
We label the classrooms . If students are in classroom for at a certain step in the process, denote by the configuration of the students.
*Step 1:* We first show that is finite. Consider the function
If a student walks into room from room , then we end up with the configuration and
with equality if and only if . Therefore, each move increases the value of by at least .
On the other hand, it is easy to check that is maximized at
Because takes only positive values, we obtain that is finite.
*Step 2:* Consider now the configuration
We claim now that any configuration may be reached from . Indeed, start from and perform moves in reverse. In the reverse procedure, students may move from a room to a room with at least two fewer students. Observe that each reverse move decreases the value of by at least and that is the only configuration where no reverse move is possible, meaning that performing a sequence of reverse moves starting at until no more reverse moves are possible will yield . Inverting these reverse moves yields the desired sequence of moves from to .
The claim implies that for any starting configuration , any sequence of moves from to may be extended to a sequence of moves from to . Thus, to find the maximum value of , it suffices for us to consider sequences of moves from to .
*Step 3:* Consider now the special configuration
Note that
By (41), increases by at least at each step. Hence it takes at most steps to move from to . We claim that this maximum of steps can be achieved when moving from to . By (41), a move decreases the value of by exactly if and only if it is between rooms with an equal number of students. Call these *good* moves. It therefore suffices to check that there exists a sequence of good moves changing into . For this, we use the following lemma.
Lemma 1. For positive integers , if there is a set of rooms with configuration for some , then there is a sequence of good moves which transforms these rooms into the configuration for .
*Proof.* Let one of the students in a room with students move to the other room with students, then the one with students, and so on, until finally he reaches the room with students. At this point, the configuration is . We may now repeat the procedure with the two rooms with students to reach the configuration . After applying this procedure times, we arrive at , as desired. □
We now prove by induction that, for , it is possible to perform a series of good moves on the first rooms of so that
(a) the numbers of students in these rooms lie in a range , where , and
(b) each integer in is represented exactly once, with the following two exceptions: Some number in , which we call the *hole*, does not appear, and if , then may occur an unlimited number of times.
For the base case , we already have such a state with . To induct from to rooms, let be the number of students in the added room (so or ). If , no moves are necessary; we may simply increase by and set to the new value of . Otherwise, apply Lemma 1 with
This yields a configuration of the desired type with and the range possibly expanded on one or both sides, completing the induction. It is easy to check that is the only placement of all students into rooms satisfying properties (a) and (b), so the final configuration in our induction is in fact .
*Step 4:* We now claim that it takes at most steps to change to . For a configuration , we consider the function
Note that if a student walks from to , then increases by . Furthermore, if or , then the sum remains unchanged. On the other hand, if , then the sum increases by . Therefore, on each move, the value of increases by at least . We may compute and
Thus, it can take at most steps to change to .
*Step 5:* We show that this upper bound can be achieved. Indeed, if we are at a configuration with (configuration satisfies this condition), we can perform the following *wave* of moves to obtain a similar configuration with one less student in and one more student in room :
Because of the assumption that , it is easy to see that the value of increases by exactly during each step in the wave. From configuration , we can perform a sequence of waves to reach configuration ; that is, we can take exactly steps from to .
*Step 6:* We claim now that for every sequence of moves with maximum length from to , there is another sequence of moves of the same length which achieves configuration along the way. Let be the sequence of moves of maximal length from to which we have just constructed; in particular, note that consists of good moves from to . Let be any other maximal sequence of moves.
We claim by induction on that there exists a sequence of moves from to with the same length as so that the first moves of and agree for , where we recall that began with good moves. The base case is vacuous. For the inductive step, we may assume by the inductive hypothesis that and agree on the first moves. Because , the move of is good; suppose that it acts on two rooms and with students. Observe that must contain some first move after the first moves involving either or . Without loss of generality, suppose that it involves . If is not a move between two rooms with students, we claim that we may lengthen by adding such a move, contradicting the maximality of . There are two cases.
* *Case 1:* A student leaves . If a student leaves for a room with more than students, we may extend by having him instead take the path .
* *Case 2:* A student enters . If a student enters from a room with less than students, we may extend by instead having a different student move from to and having the student move from to .
Therefore must involve and some other room with students. Now, construct by removing , inserting it as the move, and, in all moves after , exchanging the roles of and . This yields a valid sequence of moves because does not play a role in any moves after the move and before the original position of . The resulting sequence of moves has the same length as and matches the first moves of , completing the induction. Thus, we may rearrange the moves of so that the first agree with the first moves of , producing a maximal sequence of moves which passes through .
We conclude that all sequences of moves from to of maximal length have moves. By Step 2, this shows that the maximum value of is .