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)/最小化两个数组中的最大值 [minimize-the-maximum-of-two-arrays].html
2023-01-04 16:53:10 +08:00

53 lines
2.2 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>给你两个数组&nbsp;<code>arr1</code>&nbsp;<code>arr2</code>&nbsp;,它们一开始都是空的。你需要往它们中添加正整数,使它们满足以下条件:</p>
<ul>
<li><code>arr1</code>&nbsp;包含&nbsp;<code>uniqueCnt1</code>&nbsp;<strong>&nbsp;互不相同</strong>&nbsp;的正整数,每个整数都&nbsp;<strong>不能 </strong>&nbsp;<code>divisor1</code>&nbsp;<strong>整除</strong>&nbsp;</li>
<li><code>arr2</code>&nbsp;包含&nbsp;<code>uniqueCnt2</code>&nbsp;<strong>&nbsp;互不相同</strong>&nbsp;的正整数,每个整数都&nbsp;<strong>不能</strong>&nbsp;&nbsp;<code>divisor2</code>&nbsp;<strong>整除</strong>&nbsp;</li>
<li><code>arr1</code>&nbsp;<code>arr2</code>&nbsp;中的元素&nbsp;<strong>互不相同</strong>&nbsp;</li>
</ul>
<p>给你&nbsp;<code>divisor1</code>&nbsp;<code>divisor2</code>&nbsp;<code>uniqueCnt1</code>&nbsp;&nbsp;<code>uniqueCnt2</code>&nbsp;,请你返回两个数组中&nbsp;<strong>最大元素</strong>&nbsp;&nbsp;<strong>最小值</strong>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3
<b>输出:</b>4
<b>解释:</b>
我们可以把前 4 个自然数划分到 arr1 和 arr2 中。
arr1 = [1] 和 arr2 = [2,3,4] 。
可以看出两个数组都满足条件。
最大值是 4 ,所以返回 4 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1
<b>输出:</b>3
<b>解释:</b>
arr1 = [1,2] 和 arr2 = [3] 满足所有条件。
最大值是 3 ,所以返回 3 。</pre>
<p><strong>示例 3</strong></p>
<pre>
<b>输入:</b>divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2
<b>输出:</b>15
<b>解释:</b>
最终数组为 arr1 = [1,3,5,7,9,11,13,15] 和 arr2 = [2,6] 。
上述方案是满足所有条件的最优解。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= divisor1, divisor2 &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= uniqueCnt1, uniqueCnt2 &lt; 10<sup>9</sup></code></li>
<li><code>2 &lt;= uniqueCnt1 + uniqueCnt2 &lt;= 10<sup>9</sup></code></li>
</ul>