Skip to content

Commit e464f2e

Browse files
authored
Improved task 1547.
1 parent c06b8c9 commit e464f2e

File tree

1 file changed

+10
-2
lines changed
  • src/main/java/g1501_1600/s1547_minimum_cost_to_cut_a_stick

1 file changed

+10
-2
lines changed

src/main/java/g1501_1600/s1547_minimum_cost_to_cut_a_stick/readme.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,23 @@ Return _the minimum total cost_ of the cuts.
2222

2323
**Output:** 16
2424

25-
**Explanation:** Using cuts order = [1, 3, 4, 5] as in the input leads to the following scenario: ![](https://assets.leetcode.com/uploads/2020/07/21/e11.jpg) The first cut is done to a rod of length 7 so the cost is 7. The second cut is done to a rod of length 6 (i.e. the second part of the first cut), the third is done to a rod of length 4 and the last cut is to a rod of length 3. The total cost is 7 + 6 + 4 + 3 = 20. Rearranging the cuts to be [3, 5, 1, 4] for example will lead to a scenario with total cost = 16 (as shown in the example photo 7 + 4 + 3 + 2 = 16).
25+
**Explanation:** Using cuts order = [1, 3, 4, 5] as in the input leads to the following scenario: ![](https://assets.leetcode.com/uploads/2020/07/21/e11.jpg)
26+
27+
The first cut is done to a rod of length 7 so the cost is 7. The second cut is done to a rod of length 6 (i.e. the second part of the first cut), the third is done to a rod of length 4 and the last cut is to a rod of length 3.
28+
29+
The total cost is 7 + 6 + 4 + 3 = 20.
30+
31+
Rearranging the cuts to be [3, 5, 1, 4] for example will lead to a scenario with total cost = 16 (as shown in the example photo 7 + 4 + 3 + 2 = 16).
2632

2733
**Example 2:**
2834

2935
**Input:** n = 9, cuts = [5,6,1,4,2]
3036

3137
**Output:** 22
3238

33-
**Explanation:** If you try the given cuts ordering the cost will be 25. There are much ordering with total cost <= 25, for example, the order [4, 6, 5, 2, 1] has total cost = 22 which is the minimum possible.
39+
**Explanation:** If you try the given cuts ordering the cost will be 25.
40+
41+
There are much ordering with total cost <= 25, for example, the order [4, 6, 5, 2, 1] has total cost = 22 which is the minimum possible.
3442

3543
**Constraints:**
3644

0 commit comments

Comments
 (0)