Question: Warrior has two important attributes, magic point ( MP ) and health point ( HP ) . These two values are determined by the warrior
Warrior has two important attributes, magic pointMP and health pointHP These two values
are determined by the warrior at the beginning.
The magic city can be regarded as an undirected simple connected tree data structure with n nodes
and m edges. the warrior will walk in the city, from any starting leaf node to destination t which is
the root node. Every time the warrior passes an edge, the magic point of the warrior will be reduced
by At the same time, there is a monster with attack power on each edge, and the warrior will fight
with it If the magic point of the warrior before passing this edge is k and the attack power of the
monster on this edge is w then the battle when passing this edge will consume max w k healthy
points.
The warrior wants to ensure that his magic point and health point are both zero when reaching node
t at this time. Please find the minimum health point that the warrior needs at any beginning nodes.
For example, lets take n m and t there is only one edge with a monster whose
attack power is The warrior needs at least healthy points as the warrior will spend max
healthy points to cross this edge.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
