mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 22:13:28 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你四个整数 <code>m</code>、<code>n</code>、<code>introvertsCount</code> 和 <code>extrovertsCount</code> 。有一个 <code>m x n</code> 网格,和两种类型的人:内向的人和外向的人。总共有 <code>introvertsCount</code> 个内向的人和 <code>extrovertsCount</code> 个外向的人。</p>\n\n<p>请你决定网格中应当居住多少人,并为每个人分配一个网格单元。 注意,<strong>不必</strong> 让所有人都生活在网格中。</p>\n\n<p>每个人的 <strong>幸福感</strong> 计算如下:</p>\n\n<ul>\n\t<li>内向的人 <strong>开始</strong> 时有 <code>120</code> 个幸福感,但每存在一个邻居(内向的或外向的)他都会 <strong>失去</strong> <code>30</code> 个幸福感。</li>\n\t<li>外向的人 <strong>开始</strong> 时有 <code>40</code> 个幸福感,每存在一个邻居(内向的或外向的)他都会 <strong>得到</strong> <code>20</code> 个幸福感。</li>\n</ul>\n\n<p>邻居是指居住在一个人所在单元的上、下、左、右四个直接相邻的单元中的其他人。</p>\n\n<p><strong>网格幸福感</strong> 是每个人幸福感的 <strong>总和</strong> 。 返回 <strong>最大可能的网格幸福感</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/11/15/grid_happiness.png\" style=\"width: 261px; height: 121px;\" />\n<pre>\n<strong>输入:</strong>m = 2, n = 3, introvertsCount = 1, extrovertsCount = 2\n<strong>输出:</strong>240\n<strong>解释:</strong>假设网格坐标 (row, column) 从 1 开始编号。\n将内向的人放置在单元 (1,1) ,将外向的人放置在单元 (1,3) 和 (2,3) 。\n- 位于 (1,1) 的内向的人的幸福感:120(初始幸福感)- (0 * 30)(0 位邻居)= 120\n- 位于 (1,3) 的外向的人的幸福感:40(初始幸福感)+ (1 * 20)(1 位邻居)= 60\n- 位于 (2,3) 的外向的人的幸福感:40(初始幸福感)+ (1 * 20)(1 位邻居)= 60\n网格幸福感为:120 + 60 + 60 = 240\n上图展示该示例对应网格中每个人的幸福感。内向的人在浅绿色单元中,而外向的人在浅紫色单元中。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>m = 3, n = 1, introvertsCount = 2, extrovertsCount = 1\n<strong>输出:</strong>260\n<strong>解释:</strong>将内向的人放置在单元 (1,1) 和 (3,1) ,将外向的人放置在单元 (2,1) 。\n- 位于 (1,1) 的内向的人的幸福感:120(初始幸福感)- (1 * 30)(1 位邻居)= 90\n- 位于 (2,1) 的外向的人的幸福感:40(初始幸福感)+ (2 * 20)(2 位邻居)= 80\n- 位于 (3,1) 的内向的人的幸福感:120(初始幸福感)- (1 * 30)(1 位邻居)= 90\n网格幸福感为 90 + 80 + 90 = 260\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>m = 2, n = 2, introvertsCount = 4, extrovertsCount = 0\n<strong>输出:</strong>240\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= m, n <= 5</code></li>\n\t<li><code>0 <= introvertsCount, extrovertsCount <= min(m * n, 6)</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 39,
|
||||
"likes": 41,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"1.5K\", \"totalSubmission\": \"3.6K\", \"totalAcceptedRaw\": 1508, \"totalSubmissionRaw\": 3628, \"acRate\": \"41.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"1.6K\", \"totalSubmission\": \"3.7K\", \"totalAcceptedRaw\": 1563, \"totalSubmissionRaw\": 3721, \"acRate\": \"42.0%\"}",
|
||||
"hints": [
|
||||
"For each cell, it has 3 options, either it is empty, or contains an introvert, or an extrovert.",
|
||||
"You can do DP where you maintain the state of the previous row, the number of remaining introverts and extroverts, the current row and column, and try the 3 options for each cell.",
|
||||
|
Reference in New Issue
Block a user