leetcode174. Dungeon Game

// learn from https://discuss.leetcode.com/topic/6912/c-dp-solution
'''
class Solution {
public:
int calculateMinimumHP(vector<vector<int>>& dungeon) {
int m = dungeon.size(),n = dungeon[].size();
vector<vector<int> >dp(m+,vector<int>(n+,INT_MAX));
dp[m-][n] =;
dp[m][n-] = ;
for(int i = m-;i>=;i--){
for(int j = n-;j>=;j--){
dp[i][j] = min(dp[i][j+],dp[i+][j]) - dungeon[i][j];
dp[i][j] = max(dp[i][j],);
}
}
return dp[][];
}
};
'''
上一篇:[LeetCode] 53. Maximum Subarray 最大子数组 --动态规划+分治


下一篇:BZOJ4881 线段游戏(二分图+树状数组/动态规划+线段树)