1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-12 19:01:47 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/船上可以装载的最大集装箱数量 [maximum-containers-on-a-ship].html
2025-04-03 23:09:51 +08:00

42 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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>给你一个正整数 <code>n</code>,表示船上的一个 <code>n x n</code> 的货物甲板。甲板上的每个单元格可以装载一个重量<strong> 恰好 </strong><code>w</code> 的集装箱。</p>
<p>然而,如果将所有集装箱装载到甲板上,其总重量不能超过船的最大承载重量 <code>maxWeight</code></p>
<p>请返回可以装载到船上的 <strong>最大 </strong>集装箱数量。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 2, w = 3, maxWeight = 15</span></p>
<p><strong>输出:</strong> 4</p>
<p><strong>解释:</strong></p>
<p>甲板有 4 个单元格,每个集装箱的重量为 3。将所有集装箱装载后总重量为 12未超过 <code>maxWeight</code></p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 3, w = 5, maxWeight = 20</span></p>
<p><strong>输出:</strong> <span class="example-io">4</span></p>
<p><strong>解释:</strong></p>
<p>甲板有 9 个单元格,每个集装箱的重量为 5。可以装载的最大集装箱数量为 4此时总重量不超过 <code>maxWeight</code></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 1000</code></li>
<li><code>1 &lt;= w &lt;= 1000</code></li>
<li><code>1 &lt;= maxWeight &lt;= 10<sup>9</sup></code></li>
</ul>