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-total-damage-with-spell-casting].html
2024-06-25 01:21:44 +08:00

45 lines
1.6 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>一个魔法师有许多不同的咒语。</p>
<p>给你一个数组&nbsp;<code>power</code>&nbsp;,其中每个元素表示一个咒语的伤害值,可能会有多个咒语有相同的伤害值。</p>
<p>已知魔法师使用伤害值为&nbsp;<code>power[i]</code>&nbsp;的咒语时,他们就&nbsp;<strong>不能</strong>&nbsp;使用伤害为&nbsp;<code>power[i] - 2</code>&nbsp;<code>power[i] - 1</code>&nbsp;<code>power[i] + 1</code>&nbsp;或者&nbsp;<code>power[i] + 2</code>&nbsp;的咒语。</p>
<p>每个咒语最多只能被使用 <strong>一次</strong>&nbsp;</p>
<p>请你返回这个魔法师可以达到的伤害值之和的 <strong>最大值</strong>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>power = [1,1,3,4]</span></p>
<p><span class="example-io"><b>输出:</b>6</span></p>
<p><strong>解释:</strong></p>
<p>可以使用咒语 013伤害值分别为 114总伤害值为 6 。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>power = [7,1,6,6]</span></p>
<p><span class="example-io"><b>输出:</b>13</span></p>
<p><strong>解释:</strong></p>
<p>可以使用咒语 123伤害值分别为 166总伤害值为 13 。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= power.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= power[i] &lt;= 10<sup>9</sup></code></li>
</ul>