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

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

given a tree of n node , each node has a lable c[i] , we need to choose k nodes such that they are connected with each other and the sum of lable of k nodes is maximum. k <= n <= 5000, |c[i]| <= 10^5

input: n = 3, k = 2, c = {1, 2, 3} , edge of the tree: (1, 2), (2, 3) output: 5

i can only solve by a o(n*k^2) dp solution, please help me to solve in a better complexity. sorry for my english and thanks in advanced

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

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