# Problem №1

Misha suggested that Yulia move a chip from cell $A$ to cell $B$ along the shaded cells. In one step, you can move the chip to an adjacent cell by side or corner. To make it more interesting, Misha put 30 candies in the prize fund, but said he would take 2 candies for each horizontal or vertical move and 3 candies for each diagonal move. Yulia gets the remaining candies as a reward. What is the maximum number of candies Yulia can win?

![](https://cdn.mathpix.com/cropped/2024_05_06_91797a860d51c8d16940g-1.jpg?height=269&width=345&top_left_y=1927&top_left_x=267)
Answer: 14.

Solution. From $A$ to $B$, one can travel via the top or the bottom. If traveling via the top, the first 2 moves are diagonal (a diagonal move is more advantageous than 2 horizontal moves), and the next 5 moves are horizontal. Misha will collect $2 \cdot 3 + 5 \cdot 2 = 16$ candies, and Yulia will win 14. If traveling via the bottom, the first 5 moves are diagonal, and the last move is vertical. In this case, Misha will collect $5 \cdot 3 + 1 \cdot 2 = 17$ candies, and Yulia will win 13 candies. We conclude that the first option is more advantageous, and the win will be 14 candies.