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[][];
}
};
'''
leetcode174. Dungeon Game的更多相关文章
- leetcode-174. Dungeon Game 地下城游戏
一道关于骑士救公主故事的题目. 一些恶魔抓住了公主(P)并将她关在了地下城的右下角.地下城是由 M x N 个房间组成的二维网格.我们英勇的骑士(K)最初被安置在左上角的房间里,他必须穿过地下城并通过 ...
- [Swift]LeetCode174. 地下城游戏 | Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- [LeetCode] Dungeon Game 地牢游戏
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- POJ 2251 Dungeon Master(3D迷宫 bfs)
传送门 Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28416 Accepted: 11 ...
- poj 2251 Dungeon Master
http://poj.org/problem?id=2251 Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submis ...
- ✡ leetcode 174. Dungeon Game 地牢游戏 --------- java
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- 【leetcode】Dungeon Game
Dungeon Game The demons had captured the princess (P) and imprisoned her in the bottom-right corner ...
- Dungeon Game ——动态规划
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- Java for LeetCode 174 Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
随机推荐
- JS在路径中传中文参数
需要用 encodeURI('中文');处理一下.
- 1月12日,HTML学习笔记2
妈蛋,这两天看HTML看上瘾了,感觉这玩意有点简单,反馈期太短了,我的python都荒废了/(ㄒoㄒ)/~~. 不多说了,把记录贴上来,到时过几天再拿出来整理一下,写上注释,顺便当做复习 去研究css ...
- c# List的排序
list 是我们常用到的数据类型,我们常常会用list去处理很多的数据.我们也常常会有这样的一个操作,就是排序sort list 所在的命名空间是System.Collections.Generic ...
- linux显示器常见设置
1. 设置系统默认的分辨率 xrandr 命令: > xrandr Screen 0: minimum 1 x 1, current 1920 x 1080, maximum 8192 x 8 ...
- 判断ie版本
(function(){ var browser=navigator.appName var b_version=navigator.appVersion var version=b_version. ...
- PADS在注册表中的菜单栏数据
位于 [HKCU\Software\Mentor Graphics\PADS9_5\PADS Layout\Workspaces\ENU\Default\BCGToolBar-593980] 下的二进 ...
- java容器的一些存取用法
关于集合(list,set,map)的遍历与增强for循环的使用 java集合类的使用可以说是无处不在,总的我们可以将之分为三大块,分别是从Collection接口延伸出的List.Set和以 ...
- HackerRank "Equal Stacks"
Greedy - though simple, but fun! #include <vector> #include <iostream> using namespace s ...
- Events with Dojo(翻译)
In this tutorial, we will be exploring dojo/on and how Dojo makes it easy to connect to DOM events. ...
- ios7 ios8 cell中下划线偏移(separator Insets)处理方法
在ios7中,UITableViewCell左侧会有默认15像素的空白.这时候,设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉. 但是在ios8中,设置setS ...