← All problemsSign in

From Your GGANBU

CodeChefRating 3127Open on judge ↗

*“Do you know what someone with no money has in common with someone with too much money? Living is no fun for them.”* Gi-Hun wants to know the truth about the game and II-nam has asked him to solve this puzzle in order to get answers to his questions. Gi-Hun is given a tree consisting of $N$ nodes numbered from $1$ to $N$, **rooted at node 1**. Each node $i$ has been assigned a value $A_i$.

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