← All problemsSign in

Playing with Numbers

CodeChefRating 2087Open on judge ↗

You are given a rooted tree with $N$ nodes (numbered $1$ through $N$); node $1$ is the root. For each valid $i$, the $i$-th node has a value $v_i$ and another parameter $m_i$. A leaf is a node without sons. Let's denote the number of leaf nodes in the tree by $L$ and their numbers by $l_1, l_2, \ldots, l_L$, in increasing order. Then, for each valid $i$, let's define the *answer* for the leaf $l_

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