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)/执行操作可获得的最大总奖励 II [maximum-total-reward-using-operations-ii].html
2024-06-25 01:21:44 +08:00

46 lines
1.7 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>rewardValues</code>,长度为 <code>n</code>,代表奖励的值。</p>
<p>最初,你的总奖励 <code>x</code> 为 0所有下标都是<strong> 未标记 </strong>的。你可以执行以下操作 <strong>任意次 </strong></p>
<ul>
<li>从区间 <code>[0, n - 1]</code> 中选择一个 <strong>未标记 </strong>的下标 <code>i</code></li>
<li>如果 <code>rewardValues[i]</code> <strong>大于</strong> 你当前的总奖励 <code>x</code>,则将 <code>rewardValues[i]</code> 加到 <code>x</code> 上(即 <code>x = x + rewardValues[i]</code>),并<strong> 标记</strong> 下标 <code>i</code></li>
</ul>
<p>以整数形式返回执行最优操作能够获得的<strong> 最大</strong><em> </em>总奖励。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">rewardValues = [1,1,3,3]</span></p>
<p><strong>输出:</strong><span class="example-io">4</span></p>
<p><strong>解释:</strong></p>
<p>依次标记下标 0 和 2总奖励为 4这是可获得的最大值。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">rewardValues = [1,6,4,3,2]</span></p>
<p><strong>输出:</strong><span class="example-io">11</span></p>
<p><strong>解释:</strong></p>
<p>依次标记下标 0、2 和 1。总奖励为 11这是可获得的最大值。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= rewardValues.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= rewardValues[i] &lt;= 5 * 10<sup>4</sup></code></li>
</ul>