合并石子(最小总代价)


Submit solution


Points: 260
Time limit: 1.0s
Memory limit: 4M

Author:
Problem type
Allowed languages
C, C++
合并石子

给定一组石子,每次只能合并相邻两堆,代价为这两堆之和,求合并为一堆的最小总代价。 第一行输入n,表示有n堆石子 第二行依次输入n个整数,空格隔开

输出一个整数,合并为一堆的最小代价

输入样例:
3
3 4 3

输出:

17
数据制约

\( 1 \le n \le 300\)
\( 1 \le \text{stones}[i] \le 10^5 \)


Comments

There are no comments at the moment.