Minimum Cost required to increase the height of building to make adjacent buildings of different height

Here in this page there is sample test link, I can’t access now as the sample test is over for me. But who haven’t given this sample test they can see the questions. Please note, this is sample test not a contest so I think it would be fine to ask question.
Now the question is -:

Given n buildings, their height is given in array A and the cost of increasing height by 1 unit is given in array B so in other words, the A[i] represents the height of n^{th} building and B[i] represent the cost of increasing the height of i_{th} building by 1 unit. You have to calculate the minimum cost required after changes(if require) such that no two adjacent buildings have same height.

For example -:

A = 3 2 2 1 5
B = 5 4 6 2 3

Ans = 6.

I am not able to come up with any approach. Kindly help.

1 Like

You need to increase a building’s height twice at most and then just do a dp.