1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/卡车上的最大单元数 [maximum-units-on-a-truck].html
2022-03-29 12:43:11 +08:00

42 lines
1.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>请你将一些箱子装在 <strong>一辆卡车</strong> 上。给你一个二维数组 <code>boxTypes</code> ,其中 <code>boxTypes[i] = [numberOfBoxes<sub>i</sub>, numberOfUnitsPerBox<sub>i</sub>]</code> </p>
<ul>
<li><code>numberOfBoxes<sub>i</sub></code> 是类型 <code>i</code> 的箱子的数量。</li>
<li><code>numberOfUnitsPerBox<sub>i</sub></code><sub> </sub>是类型 <code>i</code> 每个箱子可以装载的单元数量。</li>
</ul>
<p>整数 <code>truckSize</code> 表示卡车上可以装载 <strong>箱子</strong><strong>最大数量</strong> 。只要箱子数量不超过 <code>truckSize</code> ,你就可以选择任意箱子装到卡车上。</p>
<p>返回卡车可以装载 <strong>单元</strong><strong>最大</strong> 总数<em></em></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4
<strong>输出:</strong>8
<strong>解释:</strong>箱子的情况如下:
- 1 个第一类的箱子,里面含 3 个单元。
- 2 个第二类的箱子,每个里面含 2 个单元。
- 3 个第三类的箱子,每个里面含 1 个单元。
可以选择第一类和第二类的所有箱子,以及第三类的一个箱子。
单元总数 = (1 * 3) + (2 * 2) + (1 * 1) = 8</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10
<strong>输出:</strong>91
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= boxTypes.length <= 1000</code></li>
<li><code>1 <= numberOfBoxes<sub>i</sub>, numberOfUnitsPerBox<sub>i</sub> <= 1000</code></li>
<li><code>1 <= truckSize <= 10<sup>6</sup></code></li>
</ul>