← All problemsSign in

Beautiful Garden

Farmer John wants to beautify his garden. The garden has $N$ trees. Each tree has a height $h_i$. John needs to split this garden into three parts such that each tree belongs to exactly one of the three parts and forms a continuous subsegment of the original garden. Let the sum of heights of all the trees in the first part be $H_1$, the sum of heights of trees of the second part be $H_2$ and the

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start