1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-08 00:41:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

存量题库数据更新

This commit is contained in:
2023-12-09 18:42:21 +08:00
parent a788808cd7
commit c198538f10
10843 changed files with 288489 additions and 248355 deletions

View File

@@ -2,7 +2,7 @@
"data": {
"question": {
"questionId": "3107",
"questionFrontendId": "100043",
"questionFrontendId": "2931",
"categoryTitle": "Algorithms",
"boundTopicId": 2520069,
"title": "Maximum Spending After Buying Items",
@@ -12,13 +12,38 @@
"translatedContent": "<p>给你一个下标从 <strong>0</strong>&nbsp;开始大小为&nbsp;<code>m * n</code>&nbsp;的整数矩阵&nbsp;<code>values</code>&nbsp;,表示&nbsp;<code>m</code>&nbsp;个不同商店里&nbsp;<code>m * n</code>&nbsp;件不同的物品。每个商店有 <code>n</code>&nbsp;件物品,第&nbsp;<code>i</code>&nbsp;个商店的第 <code>j</code>&nbsp;件物品的价值为&nbsp;<code>values[i][j]</code>&nbsp;。除此以外,第&nbsp;<code>i</code>&nbsp;个商店的物品已经按照价值非递增排好序了,也就是说对于所有&nbsp;<code>0 &lt;= j &lt; n - 1</code>&nbsp;都有&nbsp;<code>values[i][j] &gt;= values[i][j + 1]</code>&nbsp;。</p>\n\n<p>每一天,你可以在一个商店里购买一件物品。具体来说,在第&nbsp;<code>d</code>&nbsp;天,你可以:</p>\n\n<ul>\n\t<li>选择商店&nbsp;<code>i</code>&nbsp;。</li>\n\t<li>购买数组中最右边的物品&nbsp;<code>j</code>&nbsp;,开销为&nbsp;<code>values[i][j] * d</code>&nbsp;。换句话说,选择该商店中还没购买过的物品中最大的下标&nbsp;<code>j</code>&nbsp;,并且花费&nbsp;<code>values[i][j] * d</code>&nbsp;去购买。</li>\n</ul>\n\n<p><strong>注意</strong>,所有物品都视为不同的物品。比方说如果你已经从商店 <code>1</code>&nbsp;购买了物品&nbsp;<code>0</code>&nbsp;,你还可以在别的商店里购买其他商店的物品&nbsp;<code>0</code>&nbsp;。</p>\n\n<p>请你返回购买所有 <code>m * n</code>&nbsp;件物品需要的 <strong>最大开销</strong>&nbsp;。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<b>输入:</b>values = [[8,5,2],[6,4,1],[9,7,3]]\n<b>输出:</b>285\n<b>解释:</b>第一天,从商店 1 购买物品 2 ,开销为 values[1][2] * 1 = 1 。\n第二天从商店 0 购买物品 2 ,开销为 values[0][2] * 2 = 4 。\n第三天从商店 2 购买物品 2 ,开销为 values[2][2] * 3 = 9 。\n第四天从商店 1 购买物品 1 ,开销为 values[1][1] * 4 = 16 。\n第五天从商店 0 购买物品 1 ,开销为 values[0][1] * 5 = 25 。\n第六天从商店 1 购买物品 0 ,开销为 values[1][0] * 6 = 36 。\n第七天从商店 2 购买物品 1 ,开销为 values[2][1] * 7 = 49 。\n第八天从商店 0 购买物品 0 ,开销为 values[0][0] * 8 = 64 。\n第九天从商店 2 购买物品 0 ,开销为 values[2][0] * 9 = 81 。\n所以总开销为 285 。\n285 是购买所有 m * n 件物品的最大总开销。\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>values = [[10,8,6,4,2],[9,7,5,3,2]]\n<b>输出:</b>386\n<b>解释:</b>第一天,从商店 0 购买物品 4 ,开销为 values[0][4] * 1 = 2 。\n第二天从商店 1 购买物品 4 ,开销为 values[1][4] * 2 = 4 。\n第三天从商店 1 购买物品 3 ,开销为 values[1][3] * 3 = 9 。\n第四天从商店 0 购买物品 3 ,开销为 values[0][3] * 4 = 16 。\n第五天从商店 1 购买物品 2 ,开销为 values[1][2] * 5 = 25 。\n第六天从商店 0 购买物品 2 ,开销为 values[0][2] * 6 = 36 。\n第七天从商店 1 购买物品 1 ,开销为 values[1][1] * 7 = 49 。\n第八天从商店 0 购买物品 1 ,开销为 values[0][1] * 8 = 64 。\n第九天从商店 1 购买物品 0 ,开销为 values[1][0] * 9 = 81 。\n第十天从商店 0 购买物品 0 ,开销为 values[0][0] * 10 = 100 。\n所以总开销为 386 。\n386 是购买所有 m * n 件物品的最大总开销。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= m == values.length &lt;= 10</code></li>\n\t<li><code>1 &lt;= n == values[i].length &lt;= 10<sup>4</sup></code></li>\n\t<li><code>1 &lt;= values[i][j] &lt;= 10<sup>6</sup></code></li>\n\t<li><code>values[i]</code>&nbsp;按照非递增顺序排序。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 0,
"likes": 1,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"topicTags": [
{
"name": "Greedy",
"slug": "greedy",
"translatedName": "贪心",
"__typename": "TopicTagNode"
},
{
"name": "Array",
"slug": "array",
"translatedName": "数组",
"__typename": "TopicTagNode"
},
{
"name": "Sorting",
"slug": "sorting",
"translatedName": "排序",
"__typename": "TopicTagNode"
},
{
"name": "Heap (Priority Queue)",
"slug": "heap-priority-queue",
"translatedName": "堆(优先队列)",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
@@ -136,7 +161,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"1.3K\", \"totalSubmission\": \"2K\", \"totalAcceptedRaw\": 1298, \"totalSubmissionRaw\": 1975, \"acRate\": \"65.7%\"}",
"stats": "{\"totalAccepted\": \"2K\", \"totalSubmission\": \"2.9K\", \"totalAcceptedRaw\": 2017, \"totalSubmissionRaw\": 2915, \"acRate\": \"69.2%\"}",
"hints": [
"Iterate on days <code>1</code> to <code>m * n</code>.",
"On each day, buy the product that minimizes <code>values[i][values[i].length - 1]</code>, and pop it from <code>values[i]</code>."