Type: RemoteJudge 1000ms 128MiB

石子合并(弱化版)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

设有 N(N≤300)N(N \le 300) 堆石子排成一排,其编号为 1,2,3,⋯ ,N1,2,3,\cdots,N。每堆石子有一定的质量 mi (mi≤1000)m_i\ (m_i \le 1000)。现在要将这 NN 堆石子合并成为一堆。每次只能合并相邻的两堆,合并的代价为这两堆石子的质量之和,合并后与这两堆石子相邻的石子将和新堆相邻。合并时由于选择的顺序不同,合并的总代价也不相同。试找出一种合理的方法,使总的代价最小,并输出最小代价。

输入格式

第一行,一个整数 NN。

第二行,NN 个整数 mim_i。

输出格式

输出文件仅一个整数,也就是最小代价。

4
2 5 3 1
22

入门6 区间DP

Not Attended
Status
Done
Rule
IOI
Problem
11
Start at
2026-11-9 8:00
End at
2026-11-16 8:00
Duration
168 hour(s)
Host
Partic.
34