Merging book piles problem
Let's have N piles of books, each pile have its height, Ai.
We want to merge all piles only with one operation: merge each two piles into one. Time used to merge these two piles is equal to sum of their heights, Ai, Aj.

For example:
we have 4 piles of books
1 2 4 7
First, merge 1 with 2, total cost = 3, stack status : 3 4 7
next, merge 3 with 4, total cost = 3 + 7 = 10, stack status : 7 7
Last, merge 7 with 7, total cost = 10 + 14 = 24

How to solve this problem?

Chris
Merging book piles problem
===

Let's have N piles of books, each pile have its height, Ai.
We want to merge all piles only with one operation: merge each two piles into one. Time used to merge these two piles is equal to sum of their heights, Ai, Aj.

For example:
we have 4 piles of books
1 2 4 7
First, merge 1 with 2, total cost = 3, stack status : 3 4 7
next, merge 3 with 4, total cost = 3 + 7 = 10, stack status : 7 7
Last, merge 7 with 7, total cost = 10 + 14 = 24

How to solve this problem?

Chris