-->
当前位置:首页 > 题库

PROGRAMMING:Stone merge

Luz5年前 (2021-05-10)题库398
Place $$n $$heaps of stones around a circular playground. Now, the stones should be combined into a pile in order. It is stipulated that only two adjacent piles can be selected each time to form a new pile, and the number of stones in the new pile will be recorded as the score of the combination.
Try to design an algorithm to calculate the minimum score and the maximum score of combining $$n $$heaps into a pile.
###Input format:
The first line of the data is the positive integer $$n $, which means there are $$n $$heaps.
Line 2 has $$n $$integers and $$I $$integers $$a_ I $$indicates the number of stones in the $$I $.
###Output format:
The output has two lines, the first line has the minimum score, and the second line has the maximum score.
###Input example:
```in
four
4 5 9 4
```
###Output example:
```out
forty-three
fifty-four
```






answer:If there is no answer, please comment