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!
A very wild guess, but I'd try to think if aliens trick (aka Lagrange multipliers) works here.
https://codeforces.me/gym/102331/problem/J