Interesting problem involving tree with weighted nodes

Revision en1, by DwivediAyush, 2022-10-06 21:57:30

You are given a tree with n vertices (1,2,...,n) and each vertex has a cost associated to it given by cost[1],..., cost [n] Among all possible paths which start at u and ends at v, for any (u,v) from 1 to n, in which each vertex occurs at most once, find the cost of the path for which the value of the expression "cost of path — min(cost[u],cost[v])" is maximised.

Eg: N=3 Cost[] = {3,1,2} Edges are (1,2) and (1,3)

Answer would be 5, which is the cost of the path 2--1--3.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English DwivediAyush 2022-10-06 21:57:30 546 Initial revision (published)