← All problemsSign in

Tree Balancing

Binrohood has set out on yet another heroic ordeal of helping the poor of his village by taking money from the rich people of the village. The village has $N$ houses. There are $N-1$ roads connecting these houses. Also, these roads are arranged such a way that they do not form cycles. Each house $i$ initially has money $m_i$ in it. Binrohood also has a target money value for each house $t_i$. Bi

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