#3771

Total Score of Dungeon Runs

expert · 1120 · lc medium +32 · 30.5% accepted · 108 likes · top 8%

Description

Given a positive integer hp and 1-indexed arrays damage and requirement for n dungeon rooms (entering room i costs damage[i] HP and earns 1 point if remaining HP is at least requirement[i]), define score(j) as the total points from traversing rooms j through n in order starting with full hp (rooms cannot be skipped), then return the sum score(1) + score(2) + ... + score(n).

Code

1
2
3