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-number-of-groups-getting-fresh-donuts].html
2022-03-29 12:43:11 +08:00

33 lines
1.5 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>有一个甜甜圈商店,每批次都烤 <code>batchSize</code> 个甜甜圈。这个店铺有个规则,就是在烤一批新的甜甜圈时,之前 <strong>所有</strong> 甜甜圈都必须已经全部销售完毕。给你一个整数 <code>batchSize</code> 和一个整数数组 <code>groups</code> ,数组中的每个整数都代表一批前来购买甜甜圈的顾客,其中 <code>groups[i]</code> 表示这一批顾客的人数。每一位顾客都恰好只要一个甜甜圈。</p>
<p>当有一批顾客来到商店时,他们所有人都必须在下一批顾客来之前购买完甜甜圈。如果一批顾客中第一位顾客得到的甜甜圈不是上一组剩下的,那么这一组人都会很开心。</p>
<p>你可以随意安排每批顾客到来的顺序。请你返回在此前提下,<strong>最多</strong> 有多少组人会感到开心。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>batchSize = 3, groups = [1,2,3,4,5,6]
<b>输出:</b>4
<b>解释:</b>你可以将这些批次的顾客顺序安排为 [6,2,4,5,1,3] 。那么第 1246 组都会感到开心。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>batchSize = 4, groups = [1,3,2,5,2,2,1,6]
<b>输出:</b>4
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= batchSize <= 9</code></li>
<li><code>1 <= groups.length <= 30</code></li>
<li><code>1 <= groups[i] <= 10<sup>9</sup></code></li>
</ul>