Can anybody explain the test case how is the output is -4? It seems correct answer would be -14 if we do not do any remove operation (k=0). I posted my doubt on the actual problem page but its almost 3 days no reply from Admin. This is something not expected for active challenge.
if we remove the 2nd node then 3rd node will be deleted(as it is in its subtree).
so the node left is only 1st node.
so answer is
tree is like
having wt as 1, -5, -10 respectively
if 2nd node is removed then profit is
(sum of remaining nodes) - (X)(k) = (1) - (5)*(1) = -4
I see. Sorry for the confusion. I was removing just a single node. My bad. Thanks.
The comments section is provided for contestants to clarify their doubts. Please avoid posting doubts here as every clarification is provided to reasonable questions in the comments section. This is because, more often than not, people on this forum end up giving you some minor(if not major) hints about the problem.
Even if there is a major typo, please refrain from posting it here and instead use the comments section. The relevant people will take action immediately.
Also, read the problem statement carefully before posting questions as comments(The statement of SUBREM says “Maximum possible Sum”)
I understand your concern but I posted the comment 3 days back in the actual comment section of the problem but did not get any response. That is why I posted it here.
yeah no one replies there
i know they can’t ans all of them but they are answering none