DwivediAyush's blog

By DwivediAyush, history, 18 months ago, In English

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.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it