Problem

Source: Kyiv City MO 2025 Round 2, Problem 7.1

Tags: combinatorics



Mykhailo drew a triangular grid with side \( n \) for \( n \geq 2 \). It is formed from an equilateral triangle \( T \) with side length \( n \), by dividing each side into \( n \) equal parts. Then lines are drawn parallel to the sides of triangle \( T \), dividing it into \( n^2 \) equilateral triangles with side length \( 1 \), which we will call \textbf{cells}. Next, Oleksii writes some positive integer into each cell. Mykhailo receives 1 candy for each cell, where the number written is equal to the sum of all the numbers in the adjacent cells. Oleksii wants to arrange the numbers in such a way that Mykhailo receives the maximum number of candies. How many candies can Mykhailo receive under such conditions? In the figure below, an example is shown for \( n = 4 \) with 16 cells and numbers written inside them. For the numbers arranged as in the figure, Mykhailo receives 5 candies for the numbers \( 2 \) (the topmost cell), \( 8 \), \( 13 \), \( 12 \), and \( 11 \). Proposed by Mykhailo Shtandenko