Need help in a tree problem

Правка en1, от SliferSkyd, 2021-10-31 19:18:17

Hello everyone, can you help me with this problem:

Given a tree has N vertice (N <= 3*10^5) and a number K (K <= n — 1). Each edge in this tree has a weight W (- 10^6 <= W <= 10^6).

You should choose exactly K edges that the sum of their weight is maximum and mustn't choose 2 edges that connect with the same vertex.

I think with N and K small, this problem can be solved using dp.

Thanks!

Теги tree

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский SliferSkyd 2021-10-31 19:18:17 437 Initial revision (published)