Each fence is increased at most 2 times, so dp[i][j] is the min cost to make A[0, i] great with the last fence A[i] increased j times.
The answer is min of dp[n - 1][].
Each fence is increased at most 2 times, so dp[i][j] is the min cost to make A[0, i] great with the last fence A[i] increased j times.
The answer is min of dp[n - 1][].