Skip to content

Commit

Permalink
Create Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Apr 10, 2022
1 parent bce5828 commit f3b3b14
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Dynamic_Programming/2214.Minimum-Health-to-Beat-Game/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### 2214.Minimum-Health-to-Beat-Game

我们用dp0[i]表示通过第i关时仍未使用盔甲能够存留的最大血量,dp1[i]表示通过第i关时已经使用盔甲能够存留的最大血量,于是转移方程就是
```
dp0[i] = dp0[i] - damage[i];
dp1[i] = max(dp1[i] - damage[i], dp0[i] - max(0, damage[i]-armor));
```
我们假设初始血量是0,模拟走一遍上面的流程。由此,```max(dp0[i], dp1[i])```表示的就是通过第i关所能存留的最大血量。

要保证在通过的过程中的最大血量始终都大于0,那么就观察所有```max(dp0[i], dp1[i])```里的最低点,通过加上这个offset来保证全程的血量都不低于1.

0 comments on commit f3b3b14

Please sign in to comment.