Find the minimum cost to make the sequence good
There are N towers. The height of the ith tower is H_i. A sequence of towers is Good if there are not any two adjacent towers that have the same heights, i.e for every i (2 ≤ i ≤ N) H_i-1 != H_i condition must hold. You can increase the height of ith tower but it will cost M_i, to increase the height by 1.
You can increase the height of a tower any number of times you want. You have to just minimize the cost to make the sequence of towers Good
From the computer, choose a browser of your choice that supports the latest web trends, for example Google Chrome. You need to open the browser's code inspector, to do this on your keyboard press the keys For Mac
- Safari: Cmd(command) + Option + I
- Chrome: Cmd(command) + Option + C
- Firefox: Cmd(command) + Option + C For Windows
- Safari: Ctrl(Control) + Shift + I
- Chrome: Ctrl(Control) + Shift + C
- Firefox: Ctrl(Control) + Shift + C
Tap the Console tab. Then copy the code from the index.js file and paste it into the console editor. Finally, fill in the parameters N, H, M respectively with the suggested test cases. Verify that the values meet the requirements and constraints of the exercise.
You can also follow the steps below:
- Download VSCode to your computer https://code.visualstudio.com/download.
- Install NodeJS on your computer https://nodejs.org/en/download/current/.
- Clone the repository.
- Execute Run with NodeJS from VSCode -> in the terminal -> section "debug section" -> the output will appear.
In the .zip file you will find the images of the use cases carried out and their respective outputs