1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 07:21:40 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个&nbsp;<code>rows x cols</code> 的矩阵&nbsp;<code>grid</code>&nbsp;来表示一块樱桃地。 <code>grid</code>&nbsp;中每个格子的数字表示你能获得的樱桃数目。</p>\n\n<p>你有两个机器人帮你收集樱桃,机器人 1 从左上角格子 <code>(0,0)</code> 出发,机器人 2 从右上角格子 <code>(0, cols-1)</code> 出发。</p>\n\n<p>请你按照如下规则,返回两个机器人能收集的最多樱桃数目:</p>\n\n<ul>\n\t<li>从格子&nbsp;<code>(i,j)</code> 出发,机器人可以移动到格子&nbsp;<code>(i+1, j-1)</code><code>(i+1, j)</code> 或者&nbsp;<code>(i+1, j+1)</code>&nbsp;。</li>\n\t<li>当一个机器人经过某个格子时,它会把该格子内所有的樱桃都摘走,然后这个位置会变成空格子,即没有樱桃的格子。</li>\n\t<li>当两个机器人同时到达同一个格子时,它们中只有一个可以摘到樱桃。</li>\n\t<li>两个机器人在任意时刻都不能移动到 <code>grid</code>&nbsp;外面。</li>\n\t<li>两个机器人最后都要到达&nbsp;<code>grid</code>&nbsp;最底下一行。</li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/05/30/sample_1_1802.png\" style=\"height: 182px; width: 139px;\"></strong></p>\n\n<pre><strong>输入:</strong>grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]\n<strong>输出:</strong>24\n<strong>解释:</strong>机器人 1 和机器人 2 的路径在上图中分别用绿色和蓝色表示。\n机器人 1 摘的樱桃数目为 (3 + 2 + 5 + 2) = 12 。\n机器人 2 摘的樱桃数目为 (1 + 5 + 5 + 1) = 12 。\n樱桃总数为 12 + 12 = 24 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/05/30/sample_2_1802.png\" style=\"height: 257px; width: 284px;\"></strong></p>\n\n<pre><strong>输入:</strong>grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]\n<strong>输出:</strong>28\n<strong>解释:</strong>机器人 1 和机器人 2 的路径在上图中分别用绿色和蓝色表示。\n机器人 1 摘的樱桃数目为 (1 + 9 + 5 + 2) = 17 。\n机器人 2 摘的樱桃数目为 (1 + 3 + 4 + 3) = 11 。\n樱桃总数为 17 + 11 = 28 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><strong>输入:</strong>grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]\n<strong>输出:</strong>22\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre><strong>输入:</strong>grid = [[1,1],[1,1]]\n<strong>输出:</strong>4\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>rows == grid.length</code></li>\n\t<li><code>cols == grid[i].length</code></li>\n\t<li><code>2 &lt;= rows, cols &lt;= 70</code></li>\n\t<li><code>0 &lt;= grid[i][j] &lt;= 100&nbsp;</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 57,
"likes": 58,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"3.2K\", \"totalSubmission\": \"5.2K\", \"totalAcceptedRaw\": 3163, \"totalSubmissionRaw\": 5238, \"acRate\": \"60.4%\"}",
"stats": "{\"totalAccepted\": \"3.3K\", \"totalSubmission\": \"5.4K\", \"totalAcceptedRaw\": 3256, \"totalSubmissionRaw\": 5368, \"acRate\": \"60.7%\"}",
"hints": [
"Use dynammic programming, define DP[i][j][k]: The maximum cherries that both robots can take starting on the ith row, and column j and k of Robot 1 and 2 respectively."
],