// 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[][];
}
};
'''

leetcode174. Dungeon Game的更多相关文章

  1. leetcode-174. Dungeon Game 地下城游戏

    一道关于骑士救公主故事的题目. 一些恶魔抓住了公主(P)并将她关在了地下城的右下角.地下城是由 M x N 个房间组成的二维网格.我们英勇的骑士(K)最初被安置在左上角的房间里,他必须穿过地下城并通过 ...

  2. [Swift]LeetCode174. 地下城游戏 | Dungeon Game

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  3. [LeetCode] Dungeon Game 地牢游戏

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  4. POJ 2251 Dungeon Master(3D迷宫 bfs)

    传送门 Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28416   Accepted: 11 ...

  5. poj 2251 Dungeon Master

    http://poj.org/problem?id=2251 Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total Submis ...

  6. ✡ leetcode 174. Dungeon Game 地牢游戏 --------- java

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  7. 【leetcode】Dungeon Game

    Dungeon Game The demons had captured the princess (P) and imprisoned her in the bottom-right corner ...

  8. Dungeon Game ——动态规划

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  9. Java for LeetCode 174 Dungeon Game

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

随机推荐

  1. JS在路径中传中文参数

    需要用 encodeURI('中文');处理一下.

  2. 1月12日,HTML学习笔记2

    妈蛋,这两天看HTML看上瘾了,感觉这玩意有点简单,反馈期太短了,我的python都荒废了/(ㄒoㄒ)/~~. 不多说了,把记录贴上来,到时过几天再拿出来整理一下,写上注释,顺便当做复习 去研究css ...

  3. c# List的排序

    list 是我们常用到的数据类型,我们常常会用list去处理很多的数据.我们也常常会有这样的一个操作,就是排序sort list 所在的命名空间是System.Collections.Generic ...

  4. linux显示器常见设置

    1. 设置系统默认的分辨率 xrandr  命令: > xrandr Screen 0: minimum 1 x 1, current 1920 x 1080, maximum 8192 x 8 ...

  5. 判断ie版本

    (function(){ var browser=navigator.appName var b_version=navigator.appVersion var version=b_version. ...

  6. PADS在注册表中的菜单栏数据

    位于 [HKCU\Software\Mentor Graphics\PADS9_5\PADS Layout\Workspaces\ENU\Default\BCGToolBar-593980] 下的二进 ...

  7. java容器的一些存取用法

    关于集合(list,set,map)的遍历与增强for循环的使用     java集合类的使用可以说是无处不在,总的我们可以将之分为三大块,分别是从Collection接口延伸出的List.Set和以 ...

  8. HackerRank "Equal Stacks"

    Greedy - though simple, but fun! #include <vector> #include <iostream> using namespace s ...

  9. Events with Dojo(翻译)

    In this tutorial, we will be exploring dojo/on and how Dojo makes it easy to connect to DOM events. ...

  10. ios7 ios8 cell中下划线偏移(separator Insets)处理方法

    在ios7中,UITableViewCell左侧会有默认15像素的空白.这时候,设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉. 但是在ios8中,设置setS ...