You are given an integer hp representing your initial health points, and two integer arrays damage and requirement, each of length n.
A dungeon contains n rooms numbered from n i (i n) with an initial health of hp points and visit the rooms sequentially from room i to room n
In each run starting from room i:
When you enter room j (i j n), your health points decrease by damage[j].
If your remaining health points after taking damage are greater than or equal to requirement[j], you earn
Let score(i) be the total points earned when starting the run from room i.
Return the total score obtained by summing score(i) across all possible starting rooms i from n
Constraints:
hp
n damage.length requirement.length
damage[i], requirement[i]
You are given an integer hp representing your initial health points, and two integer arrays damage and requirement, each of length n.
A dungeon contains n rooms numbered from n i (i n) with an initial health of hp points and visit the rooms sequentially from room i to room n
In each run starting from room i:
When you enter room j (i j n), your health points decrease by damage[j].
If your remaining health points after taking damage are greater than or equal to requirement[j], you earn
Let score(i) be the total points earned when starting the run from room i.
Return the total score obtained by summing score(i) across all possible starting rooms i from n
Constraints:
hp
n damage.length requirement.length
damage[i], requirement[i]