1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 15:31:43 +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>n</code>&nbsp;道菜的满意程度&nbsp;<code>satisfaction</code>&nbsp;,这个厨师做出每道菜的时间都是 1 单位时间。</p>\n\n<p>一道菜的 「喜爱时间」系数定义为烹饪这道菜以及之前每道菜所花费的时间乘以这道菜的满意程度,也就是&nbsp;<code>time[i]</code>*<code>satisfaction[i]</code>&nbsp;。</p>\n\n<p>请你返回做完所有菜 「喜爱时间」总和的最大值为多少。</p>\n\n<p>你可以按&nbsp;<strong>任意</strong>&nbsp;顺序安排做菜的顺序,你也可以选择放弃做某些菜来获得更大的总和。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>satisfaction = [-1,-8,0,5,-9]\n<strong>输出:</strong>14\n<strong>解释:</strong>去掉第二道和最后一道菜,最大的喜爱时间系数和为 (-1*1 + 0*2 + 5*3 = 14) 。每道菜都需要花费 1 单位时间完成。</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>satisfaction = [4,3,2]\n<strong>输出:</strong>20\n<strong>解释:</strong>按照原来顺序相反的时间做菜 (2*1 + 3*2 + 4*3 = 20)\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>satisfaction = [-1,-4,-5]\n<strong>输出:</strong>0\n<strong>解释:</strong>大家都不喜欢这些菜,所以不做任何菜可以获得最大的喜爱时间系数。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == satisfaction.length</code></li>\n\t<li><code>1 &lt;= n &lt;= 500</code></li>\n\t<li><code>-1000 &lt;= satisfaction[i] &lt;= 1000</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 92,
"likes": 93,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"11.2K\", \"totalSubmission\": \"14.8K\", \"totalAcceptedRaw\": 11223, \"totalSubmissionRaw\": 14841, \"acRate\": \"75.6%\"}",
"stats": "{\"totalAccepted\": \"11.6K\", \"totalSubmission\": \"15.3K\", \"totalAcceptedRaw\": 11576, \"totalSubmissionRaw\": 15264, \"acRate\": \"75.8%\"}",
"hints": [
"Use dynamic programming to find the optimal solution by saving the previous best like-time coefficient and its corresponding element sum.",
"If adding the current element to the previous best like-time coefficient and its corresponding element sum would increase the best like-time coefficient, then go ahead and add it. Otherwise, keep the previous best like-time coefficient."