← All problemsSign in

Treats on a Tree

Chef is teaching his dog Sudo about computer science. In the most recent lessons, Chef draws up a track on the floor in the shape of a tree with N vertices. At each vertex is placed a bowl. The bowl at vertex i contains wi treats. Before the test starts, Chef allows Sudo to observe the whole structure. Then Chef chooses a starting vertex, and permits Sudo to move from vertex to vertex only if an e

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