// 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. LeetCode-Search a 2D Matrix

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  2. 树莓派(Raspberry Pi)日期时间不准的修正方法

    在树莓派上,打date命令可以看到系统的日期时间: 后面的CST表示中国标准时间 小知识: 树莓派没有电池,断电后无法保存时间. 树莓派默认安装了NTP(Network Time Protocol)服 ...

  3. 判断ie版本

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

  4. jsonP跨域调用

    -------------------------------------jsonP跨域调用------------------------------------- <div class=&q ...

  5. BarTender如何将条码下的数字嵌入到条码中

    现今社会,在各种包装箱子.书籍.超市商品等东西上面,必不可少的绝对要数条形码或者二维码了.有时候,根据客户的需求或者其他条件限制等原因,我们需要将BarTender 2016条码下的数字嵌入到条码中. ...

  6. yii框架中的一些小细节配置问题

    1.查看运行时间'db'=>array(      'connectionString' => 'mysql:host=localhost;dbname=shop',      'emul ...

  7. # C/C++的笔试题目

    p,li { white-space: pre-wrap } # C/C++的笔试题目 + include<> 和include"" 的区别 + sizeof操作符与字 ...

  8. QQ通信原理及QQ是怎么穿透内网进行通信的? (转)

    原:http://f543711700.iteye.com/blog/978044#bc2344608 QQ是一个基于TCP/UDP协议的通讯软件 发送消息的时候是UDP打洞,登陆的时候使用HTTP~ ...

  9. CocoaPods使用详细说明

    使用说明: 原文:http://blog.csdn.net/lizhongfu2013/article/details/26384029 http://blog.csdn.net/showhillle ...

  10. C#:调用webservice时提示对操作的回复消息正文进行反序列化时出错

    主要原因webservice返回值的长度超过readerQuotas中的了maxStringContentLength值,造成返回值截断,不完整,反序列化时出错. <readerQuotas m ...