题目地址:POJ3666
dp[i][j]表示第i位时,值为j时的最小代价。因为j太大,由于要改变值的话,变到与之最近的值相同是最优的,所以可以离散化,这样,j对应了各个值得下标。复杂度O(n^2)。
代码如下:#include
#include
#include
#include
#include <algorith...
分类:
其他好文 时间:
2015-03-13 10:58:05
阅读次数:
154
DescriptionA straight dirt road connects two fields on FJ’s farm, but it changes elevation more than FJ would like. His cows do not mind climbing up or down a single slope, but they are not fond of an...
分类:
其他好文 时间:
2015-02-14 15:02:57
阅读次数:
157