Блог пользователя DwivediAyush

Автор DwivediAyush, история, 19 месяцев назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится