Problem 2646 · Hard

Minimize the Total Price of the Trips

Count how often each node is used by the trips, then run a tree DP that halves a node only when its neighbours are not halved.

Open the interactive visualisation