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)/最佳观光组合 [best-sightseeing-pair].html
2022-03-29 12:43:11 +08:00

32 lines
1.0 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>values</code>,其中 <code>values[i]</code> 表示第 <code>i</code> 个观光景点的评分,并且两个景点 <code>i</code> 和 <code>j</code> 之间的 <strong>距离</strong> 为 <code>j - i</code></p>
<p>一对景点(<code>i < j</code>)组成的观光组合的得分为 <code>values[i] + values[j] + i - j</code> ,也就是景点的评分之和<strong> 减去 </strong>它们两者之间的距离。</p>
<p>返回一对观光景点能取得的最高分。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>values = [8,1,5,2,6]
<strong>输出:</strong>11
<strong>解释:</strong>i = 0, j = 2, values[i] + values[j] + i - j = 8 + 5 + 0 - 2 = 11
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>values = [1,2]
<strong>输出:</strong>2
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 <= values.length <= 5 * 10<sup>4</sup></code></li>
<li><code>1 <= values[i] <= 1000</code></li>
</ul>