|
6 | 6 |
|
7 | 7 | <!-- 这里写题目描述 -->
|
8 | 8 |
|
9 |
| -<p>有 <code>N</code> 堆石头排成一排,第 <code>i</code> 堆中有 <code>stones[i]</code> 块石头。</p> |
| 9 | +<p>有 <code>n</code> 堆石头排成一排,第 <code>i</code> 堆中有 <code>stones[i]</code> 块石头。</p> |
10 | 10 |
|
11 |
| -<p>每次<em>移动(move)</em>需要将<strong>连续的</strong> <code>K</code> 堆石头合并为一堆,而这个移动的成本为这 <code>K</code> 堆石头的总数。</p> |
| 11 | +<p>每次 <strong>移动</strong> 需要将 <strong>连续的</strong> <code>k</code> 堆石头合并为一堆,而这次移动的成本为这 <code>k</code> 堆中石头的总数。</p> |
12 | 12 |
|
13 |
| -<p>找出把所有石头合并成一堆的最低成本。如果不可能,返回 <code>-1</code> 。</p> |
| 13 | +<p>返回把所有石头合并成一堆的最低成本。如果无法合并成一堆,返回 <code>-1</code> 。</p> |
14 | 14 |
|
15 | 15 | <p> </p>
|
16 | 16 |
|
17 | 17 | <p><strong>示例 1:</strong></p>
|
18 | 18 |
|
19 |
| -<pre><strong>输入:</strong>stones = [3,2,4,1], K = 2 |
| 19 | +<pre> |
| 20 | +<strong>输入:</strong>stones = [3,2,4,1], K = 2 |
20 | 21 | <strong>输出:</strong>20
|
21 | 22 | <strong>解释:</strong>
|
22 | 23 | 从 [3, 2, 4, 1] 开始。
|
|
28 | 29 |
|
29 | 30 | <p><strong>示例 2:</strong></p>
|
30 | 31 |
|
31 |
| -<pre><strong>输入:</strong>stones = [3,2,4,1], K = 3 |
| 32 | +<pre> |
| 33 | +<strong>输入:</strong>stones = [3,2,4,1], K = 3 |
32 | 34 | <strong>输出:</strong>-1
|
33 | 35 | <strong>解释:</strong>任何合并操作后,都会剩下 2 堆,我们无法再进行合并。所以这项任务是不可能完成的。.
|
34 | 36 | </pre>
|
35 | 37 |
|
36 | 38 | <p><strong>示例 3:</strong></p>
|
37 | 39 |
|
38 |
| -<pre><strong>输入:</strong>stones = [3,5,1,2,6], K = 3 |
| 40 | +<pre> |
| 41 | +<strong>输入:</strong>stones = [3,5,1,2,6], K = 3 |
39 | 42 | <strong>输出:</strong>25
|
40 | 43 | <strong>解释:</strong>
|
41 | 44 | 从 [3, 5, 1, 2, 6] 开始。
|
|
49 | 52 | <p><strong>提示:</strong></p>
|
50 | 53 |
|
51 | 54 | <ul>
|
52 |
| - <li><code>1 <= stones.length <= 30</code></li> |
53 |
| - <li><code>2 <= K <= 30</code></li> |
| 55 | + <li><code>n == stones.length</code></li> |
| 56 | + <li><code>1 <= n <= 30</code></li> |
54 | 57 | <li><code>1 <= stones[i] <= 100</code></li>
|
| 58 | + <li><code>2 <= k <= 30</code></li> |
55 | 59 | </ul>
|
56 | 60 |
|
57 | 61 | ## 解法
|
|
0 commit comments