#Lutece0599. 最少花费
最少花费
Migrated from Lutece 599 最少花费
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Bob是一个魔法师。这天,他被座山所阻挡,这些山排成一排,每座山有一个高度。Bob需要从左往右每次跳到相邻的一座山上,相邻的两座山的高度差不能超过,当从高度差为的一座山跳到另一座山时要花的魔法值。Bob可以改变一座山的高度,但调整后的高度不能小于或大于,改变的高度需要花费的魔法值。现在已知每座山的高度,求Bob跳完所有山后魔法值的最少花费。
Input
第一行一个整数(),表示数据组数。
每组第一行有个整数(), (), ()。
接下来个整数,按从左往右的顺序表示山的高度,山的高度在到之间。
Output
对于每组数据,输出一个整数,表示最少花费。
Samples
2
1 1 1
1
3 1 10
1 2 3
0
2
Resources
UESTC Training for Dynamic Programming