Breaking the Tree
CodeChefOpen on judge ↗
You are given a tree with N vertices where each vertex has an associated weight A[i]. Let’s call the sum of all weights in a tree W. Removing any edge from the tree will result in two trees, with the sums of each tree being, W1 and W2. You will be given Q queries. Each query will have an integer D-short for difference. You should output whether it is possible to remove an edge from the tree, break
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.
Sign in to chat with the tutor and save your progress.
Sign in to start