mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 08:21:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给定一个数组 <code>books</code> ,其中 <code>books[i] = [thickness<sub>i</sub>, height<sub>i</sub>]</code> 表示第 <code>i</code> 本书的厚度和高度。你也会得到一个整数 <code>shelfWidth</code> 。</p>\n\n<p><strong>按顺序</strong> 将这些书摆放到总宽度为 <code>shelfWidth</code> 的书架上。</p>\n\n<p>先选几本书放在书架上(它们的厚度之和小于等于书架的宽度 <code>shelfWidth</code> ),然后再建一层书架。重复这个过程,直到把所有的书都放在书架上。</p>\n\n<p>需要注意的是,在上述过程的每个步骤中,<strong>摆放书的顺序与你整理好的顺序相同</strong>。</p>\n\n<ul>\n\t<li>例如,如果这里有 5 本书,那么可能的一种摆放情况是:第一和第二本书放在第一层书架上,第三本书放在第二层书架上,第四和第五本书放在最后一层书架上。</li>\n</ul>\n\n<p>每一层所摆放的书的最大高度就是这一层书架的层高,书架整体的高度为各层高之和。</p>\n\n<p>以这种方式布置书架,返回书架整体可能的最小高度。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img src=\"https://assets.leetcode.com/uploads/2019/06/24/shelves.png\" style=\"width: 337px; height: 500px;\" /></p>\n\n<pre>\n<strong>输入:</strong>books = [[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelf_width = 4\n<strong>输出:</strong>6\n<strong>解释:</strong>\n3 层书架的高度和为 1 + 3 + 2 = 6 。\n第 2 本书不必放在第一层书架上。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong> books = [[1,3],[2,4],[3,2]], shelfWidth = 6\n<strong>输出:</strong> 4\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= books.length <= 1000</code></li>\n\t<li><code>1 <= thickness<sub>i</sub> <= shelfWidth <= 1000</code></li>\n\t<li><code>1 <= height<sub>i</sub> <= 1000</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 127,
|
||||
"likes": 131,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"5.9K\", \"totalSubmission\": \"10.4K\", \"totalAcceptedRaw\": 5867, \"totalSubmissionRaw\": 10353, \"acRate\": \"56.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"6K\", \"totalSubmission\": \"10.6K\", \"totalAcceptedRaw\": 6020, \"totalSubmissionRaw\": 10604, \"acRate\": \"56.8%\"}",
|
||||
"hints": [
|
||||
"Use dynamic programming: dp(i) will be the answer to the problem for books[i:]."
|
||||
],
|
||||
|
Reference in New Issue
Block a user