Browse · MathNet
PrintIMO2024 Shortlisted Problems
2024 counting and probability
Problem
Let and be positive integers. James has marbles with weights . He places them on a balance scale, so that both sides have equal weight. Andrew may move a marble from one side of the scale to the other, so that the absolute difference in weights of the two sides remains at most . Find, in terms of , the minimum positive integer such that Andrew may make a sequence of moves such that each marble ends up on the opposite side of the scale, regardless of how James initially placed the marbles.
Solution
Consider partitioning the weights into pairs . Suppose that each side of the balance contains of those pairs. If one side of the balance contains the pair for and the other side contains , then the following sequence of moves swaps those pairs between the sides without ever increasing the absolute value of the difference above .
Applying this sequence twice swaps any two pairs and between the sides. So we can achieve an arbitrary exchange of pairs between the sides, and can be any configuration where each side of the balance contains of those pairs.
We now show that any initial configuration can reach one where each side has of those pairs. Consider a configuration where one side has total weight and the other has total weight , for some , and where some pair is split between the two sides. (If no pair is split between the two sides, they must have equal weights and we are done.) Valid moves include moving any weight with from the side to the side, and moving any weight with from the side to the side. Suppose the pair , with , is split between the sides. If is on the side, or on the side and , it can be moved to the other side. Otherwise, is on the side and , so is on the side and can be moved to the other side. So we can unite the two weights from that pair without splitting any other pair, and repeating this we reach a configuration where no pair is split between the sides.
We treat the case separately. The initial configuration has marbles on one side and on the other. So moving marbles in that order is legal and every marble ends on the opposite side. Now assume .
Marbles of weight at most are called small. We will make use of the following lemmas:
Lemma 1. If a pair of legal configurations differ only in the locations of small marbles then there is a sequence of legal moves to get from one to the other.
Proof. At first we only move marbles in the wrong position if they are not on the lighter side. (In the case of a tie, neither side is lighter.) Such a move is always legal. Since this reduces the number of marbles in the wrong position, eventually it will no longer be possible to perform such a move.
Then the only marbles in the wrong position are on the lighter side. So moving one marble in the wrong position at a time will always increase , and at the end. Hence every move is legal.
Lemma 2. Let . A positive integer can be expressed as a sum of distinct positive integers up to if and only if it is at most .
Proof. The maximum possible sum of distinct positive integers up to is . For the other direction we use induction on . The case is trivial. Assume the statement is true for . For positive integers up to we only need a single term. For larger integers, including in the expression means we are done by the inductive hypothesis.
Also note that for .
Let . Marbles of weight greater than are called big and marbles from to are called medium.
Suppose all big marbles are on the correct side (that is, opposite where they started), is on the incorrect side and the configuration is legal. Then the following steps give a sequence of legal moves after which is on the correct side and the big marbles were never moved.
Assume is on the left. In Step 2, we rearrange the small marbles so we can move . But this is only possible if the weight of big and medium marbles on the right is not too large. So we may need to move some medium marbles from the right first, which we do in Step 1.
Step 1 Skip to Step 2 if the total weight of medium and big marbles on the right side is at most . Since the big marbles are in the correct position and is in the incorrect position, the big marbles on the right can weigh at most . So there must be a medium marble on the right.
From the first assumption, it is legal to move all small marbles to the left. Then by Lemma 2 we can move some of the small marbles to the right so the right side has weight exactly . Then moving is legal. Repeat this step. Since the total weight of medium marbles on the right decreases, this step will occur a bounded number of times.
Step 2 Let the total weight of the right side be and the weight of small marbles on the right side be . Note that . If then moving is legal.
Otherwise, by Lemma 2 there is a set of small marbles of weight . By Lemma 1, there is a sequence of legal moves of small marbles such that the right side has weight exactly . Now moving is legal.
Applying the process above for will move all nonsmall marbles to the opposite side. Then Lemma 1 completes the proof.
Applying this sequence twice swaps any two pairs and between the sides. So we can achieve an arbitrary exchange of pairs between the sides, and can be any configuration where each side of the balance contains of those pairs.
We now show that any initial configuration can reach one where each side has of those pairs. Consider a configuration where one side has total weight and the other has total weight , for some , and where some pair is split between the two sides. (If no pair is split between the two sides, they must have equal weights and we are done.) Valid moves include moving any weight with from the side to the side, and moving any weight with from the side to the side. Suppose the pair , with , is split between the sides. If is on the side, or on the side and , it can be moved to the other side. Otherwise, is on the side and , so is on the side and can be moved to the other side. So we can unite the two weights from that pair without splitting any other pair, and repeating this we reach a configuration where no pair is split between the sides.
We treat the case separately. The initial configuration has marbles on one side and on the other. So moving marbles in that order is legal and every marble ends on the opposite side. Now assume .
Marbles of weight at most are called small. We will make use of the following lemmas:
Lemma 1. If a pair of legal configurations differ only in the locations of small marbles then there is a sequence of legal moves to get from one to the other.
Proof. At first we only move marbles in the wrong position if they are not on the lighter side. (In the case of a tie, neither side is lighter.) Such a move is always legal. Since this reduces the number of marbles in the wrong position, eventually it will no longer be possible to perform such a move.
Then the only marbles in the wrong position are on the lighter side. So moving one marble in the wrong position at a time will always increase , and at the end. Hence every move is legal.
Lemma 2. Let . A positive integer can be expressed as a sum of distinct positive integers up to if and only if it is at most .
Proof. The maximum possible sum of distinct positive integers up to is . For the other direction we use induction on . The case is trivial. Assume the statement is true for . For positive integers up to we only need a single term. For larger integers, including in the expression means we are done by the inductive hypothesis.
Also note that for .
Let . Marbles of weight greater than are called big and marbles from to are called medium.
Suppose all big marbles are on the correct side (that is, opposite where they started), is on the incorrect side and the configuration is legal. Then the following steps give a sequence of legal moves after which is on the correct side and the big marbles were never moved.
Assume is on the left. In Step 2, we rearrange the small marbles so we can move . But this is only possible if the weight of big and medium marbles on the right is not too large. So we may need to move some medium marbles from the right first, which we do in Step 1.
Step 1 Skip to Step 2 if the total weight of medium and big marbles on the right side is at most . Since the big marbles are in the correct position and is in the incorrect position, the big marbles on the right can weigh at most . So there must be a medium marble on the right.
From the first assumption, it is legal to move all small marbles to the left. Then by Lemma 2 we can move some of the small marbles to the right so the right side has weight exactly . Then moving is legal. Repeat this step. Since the total weight of medium marbles on the right decreases, this step will occur a bounded number of times.
Step 2 Let the total weight of the right side be and the weight of small marbles on the right side be . Note that . If then moving is legal.
Otherwise, by Lemma 2 there is a set of small marbles of weight . By Lemma 1, there is a sequence of legal moves of small marbles such that the right side has weight exactly . Now moving is legal.
Applying the process above for will move all nonsmall marbles to the opposite side. Then Lemma 1 completes the proof.
Final answer
4n
Techniques
Invariants / monovariantsInduction / smoothingGames / greedy algorithms