mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-24 22:38:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个 <code>m x n</code> 的整数矩阵 <code>points</code> (下标从 <strong>0</strong> 开始)。一开始你的得分为 <code>0</code> ,你想最大化从矩阵中得到的分数。</p>\n\n<p>你的得分方式为:<strong>每一行</strong> 中选取一个格子,选中坐标为 <code>(r, c)</code> 的格子会给你的总得分 <strong>增加</strong> <code>points[r][c]</code> 。</p>\n\n<p>然而,相邻行之间被选中的格子如果隔得太远,你会失去一些得分。对于相邻行 <code>r</code> 和 <code>r + 1</code> (其中 <code>0 <= r < m - 1</code>),选中坐标为 <code>(r, c<sub>1</sub>)</code> 和 <code>(r + 1, c<sub>2</sub>)</code> 的格子,你的总得分 <b>减少</b> <code>abs(c<sub>1</sub> - c<sub>2</sub>)</code> 。</p>\n\n<p>请你返回你能得到的 <strong>最大</strong> 得分。</p>\n\n<p><code>abs(x)</code> 定义为:</p>\n\n<ul>\n\t<li>如果 <code>x >= 0</code> ,那么值为 <code>x</code> 。</li>\n\t<li>如果 <code>x < 0</code> ,那么值为 <code>-x</code> 。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/07/12/screenshot-2021-07-12-at-13-40-26-diagram-drawio-diagrams-net.png\" style=\"width: 300px; height: 300px;\" />\n<pre>\n<b>输入:</b>points = [[1,2,3],[1,5,1],[3,1,1]]\n<b>输出:</b>9\n<strong>解释:</strong>\n蓝色格子是最优方案选中的格子,坐标分别为 (0, 2),(1, 1) 和 (2, 0) 。\n你的总得分增加 3 + 5 + 3 = 11 。\n但是你的总得分需要扣除 abs(2 - 1) + abs(1 - 0) = 2 。\n你的最终得分为 11 - 2 = 9 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/07/12/screenshot-2021-07-12-at-13-42-14-diagram-drawio-diagrams-net.png\" style=\"width: 200px; height: 299px;\" />\n<pre>\n<b>输入:</b>points = [[1,5],[2,3],[4,2]]\n<b>输出:</b>11\n<strong>解释:</strong>\n蓝色格子是最优方案选中的格子,坐标分别为 (0, 1),(1, 1) 和 (2, 0) 。\n你的总得分增加 5 + 3 + 4 = 12 。\n但是你的总得分需要扣除 abs(1 - 1) + abs(1 - 0) = 1 。\n你的最终得分为 12 - 1 = 11 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>m == points.length</code></li>\n\t<li><code>n == points[r].length</code></li>\n\t<li><code>1 <= m, n <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= m * n <= 10<sup>5</sup></code></li>\n\t<li><code>0 <= points[r][c] <= 10<sup>5</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 66,
|
||||
"likes": 67,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -130,7 +130,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"3.8K\", \"totalSubmission\": \"14.6K\", \"totalAcceptedRaw\": 3767, \"totalSubmissionRaw\": 14551, \"acRate\": \"25.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"3.8K\", \"totalSubmission\": \"14.7K\", \"totalAcceptedRaw\": 3841, \"totalSubmissionRaw\": 14741, \"acRate\": \"26.1%\"}",
|
||||
"hints": [
|
||||
"Try using dynamic programming.",
|
||||
"dp[i][j] is the maximum number of points you can have if points[i][j] is the most recent cell you picked."
|
||||
|
||||
Reference in New Issue
Block a user