mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
64 lines
2.1 KiB
HTML
64 lines
2.1 KiB
HTML
<p>给你两个整数 <code>red</code> 和 <code>blue</code>,分别表示红色球和蓝色球的数量。你需要使用这些球来组成一个三角形,满足第 1 行有 1 个球,第 2 行有 2 个球,第 3 行有 3 个球,依此类推。</p>
|
||
|
||
<p>每一行的球必须是 <strong>相同 </strong>颜色,且相邻行的颜色必须<strong> 不同</strong>。</p>
|
||
|
||
<p>返回可以实现的三角形的 <strong>最大 </strong>高度。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong class="example">示例 1:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">red = 2, blue = 4</span></p>
|
||
|
||
<p><strong>输出:</strong> 3</p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/06/16/brb.png" style="width: 300px; height: 240px; padding: 10px;" /></p>
|
||
|
||
<p>上图显示了唯一可能的排列方式。</p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 2:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">red = 2, blue = 1</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">2</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/06/16/br.png" style="width: 150px; height: 135px; padding: 10px;" /><br />
|
||
上图显示了唯一可能的排列方式。</p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 3:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">red = 1, blue = 1</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">1</span></p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 4:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">red = 10, blue = 1</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">2</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/06/16/br.png" style="width: 150px; height: 135px; padding: 10px;" /><br />
|
||
上图显示了唯一可能的排列方式。</p>
|
||
</div>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= red, blue <= 100</code></li>
|
||
</ul>
|