2646. Minimize the Total Price of the Trips
There exists an undirected and unrooted tree with
nnodes indexed from0ton - 1. You are given the integernand a 2D integer arrayedgesof lengthn - 1, whereedges[i] = [ai, bi]indicates that there is an edge between nodesaiandbiin the tree.Each node has an associated price. You are given an integer array
price, whereprice[i]is the price of theithnode.The price sum of a given path is the sum of the prices of all nodes lying on that path.
Additionally, you are given a 2D integer array
trips, wheretrips[i] = [starti, endi]indicates that you start theithtrip from the nodestartiand travel to the nodeendiby any path you like.Before performing your first trip, you can choose some non-adjacent nodes and halve the prices.
Return the minimum total price sum to perform all the given trips.