Maths Olympiad Prep

Library / /3 of 3

Combinatorics Difficulty 7.7 National olympiad, round 2 Prove it South Korea

Let nn be a positive integer. There are nn boxes B1,B2,,BnB_1, B_2, \dots, B_n each of which contains some balls. One can perform the following moves.
Choose positive integers ii and jj with 1ijn1 \le i \le j \le n, and add exactly one ball to each of the boxes Bi,Bi+1,,BjB_i, B_{i+1}, \dots, B_j.
For positive integers x1,x2,,xnx_1, x_2, \dots, x_n, let f(x1,x2,,xn)f(x_1, x_2, \dots, x_n) be the minimum number of moves required to make the number of balls in each of boxes divisible by 33, starting from xix_i balls in BiB_i for each i=1,2,,ni = 1, 2, \dots, n. Find the maximum value of f(x1,x2,,xn)f(x_1, x_2, \dots, x_n).
(If 3xi3|x_i for i=1,2,,ni = 1, 2, \dots, n, then f(x1,x2,,xn)=0f(x_1, x_2, \dots, x_n) = 0)

Solution

The answer is 2n+23\left\lceil \frac{2n+2}{3} \right\rceil.

For i=0,1,,ni = 0, 1, \dots, n, let yi=xixi+1y_i = x_i - x_{i+1} where x0=xn+1=0x_0 = x_{n+1} = 0. Note that y0+y1++yn=0y_0 + y_1 + \dots + y_n = 0. The move in the problem is equivalent to the following.
Choose non-negative integers ii and jj with 0i<jn0 \le i < j \le n, and replace yiy_i and yjy_j by yi1y_i - 1 and yj+1y_j + 1, respectively.
We call this move the (i,j)(i, j)-move. Our goal is to make each yiy_i a multiple of 33. Now we prove that for every sequence of integers y0,y1,,yny_0, y_1, \dots, y_n with y0+y1++yn=0y_0 + y_1 + \dots + y_n = 0, we can make each of yiy_i's a multiple of 33 by performing at most 2n+23\left\lceil \frac{2n+2}{3} \right\rceil moves.

We use induction on nn.
One can easily check that it is possible when n=1,2n = 1, 2.
Suppose n>2n > 2. If 3yi3|y_i for some ii, then we can ignore yiy_i, and so we need at most 2n3\left\lceil \frac{2n}{3} \right\rceil moves to make all yiy_i's multiples of 33. Hence, we may assume that yi0y_i \ne 0 for each ii. We consider the following four cases.

Case 1. There exist 0i<jn0 \le i < j \le n such that yi1(mod3)y_i \equiv 1 \pmod{3} and yj2(mod3)y_j \equiv 2 \pmod{3}.
Then, we perform the (i,j)(i, j)-move then yiy_i and yjy_j become multiples of 33. So, in this case, we need at most 1+2n232n+231 + \left\lceil \frac{2n-2}{3} \right\rceil \le \left\lceil \frac{2n+2}{3} \right\rceil moves.

Case 2. There exist 0i<j<kn0 \le i < j < k \le n such that yiyjyk1(mod3)y_i \equiv y_j \equiv y_k \equiv 1 \pmod{3}.
Then, we perform the (i,k)(i, k)-move and the (j,k)(j, k)-move. Then, yi,yjy_i, y_j and yky_k become multiples of 33. So, we need at most 2+2n43=2n+232 + \left\lceil \frac{2n-4}{3} \right\rceil = \left\lceil \frac{2n+2}{3} \right\rceil moves.

Case 3. There exist 0i<j<kn0 \le i < j < k \le n such that yiyjyk2(mod3)y_i \equiv y_j \equiv y_k \equiv 2 \pmod{3}.
Then, we perform the (i,j)(i, j)-move and the (i,k)(i, k)-move. Then, yi,yjy_i, y_j and yky_k become multiples of 33. So, we need at most 2+2n43=2n+232 + \left\lceil \frac{2n-4}{3} \right\rceil = \left\lceil \frac{2n+2}{3} \right\rceil moves.

Case 4. Neither case 1, case 2 nor case 3 occurs.
Since n3n \ge 3, the only possible case is that n=3n = 3 and (y0,y1,y2,y3)(2,2,1,1)(mod3)(y_0, y_1, y_2, y_3) \equiv (2, 2, 1, 1) \pmod{3}. In this case, we perform the (0, 1)-move, the (0, 3)-move and the (2, 3)-move. Then, each yiy_i becomes a multiple of 33.

Therefore, by the induction, we can make each yiy_i a multiple of 33 by performing at most 2n+23\left\lceil \frac{2n+2}{3} \right\rceil moves.

Finally, for the following cases, we need at least 2n+23\left\lceil \frac{2n+2}{3} \right\rceil moves, which implies that the answer is 2n+23\left\lceil \frac{2n+2}{3} \right\rceil.

(y0,y1,,yn)={(2,2,,2,2,2),if n2(mod3)(2,2,,2,2,1),(2,2,,2,1,2)if n1(mod3)(2,2,,2,1,1),if n0(mod3) (y_0, y_1, \dots, y_n) = \begin{cases} (2, 2, \dots, 2, 2, 2), & \text{if } n \equiv 2 \pmod{3} \\ (2, 2, \dots, 2, 2, 1), (2, 2, \dots, 2, 1, 2) & \text{if } n \equiv 1 \pmod{3} \\ (2, 2, \dots, 2, 1, 1), & \text{if } n \equiv 0 \pmod{3} \end{cases}

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement and solution reproduced as published; topic and difficulty added by this site.