Least Amount Required for Stone Removal

Правка en1, от samadeep, 2023-06-15 18:08:30

Recently i came accross this question it would be great if anyone could solve this.

There are 'n' stones in a row from 0 to n-1. For every ith stone , there are 2 values associated with it, a[i] and b[i] . You have to remove all the stones from the row one by one. Removing the ith stone follows the rule : **** If (i-1)th and (i+1)th stones are still present , then , cost of removing the ith stone is b[i]. **** if either (i-1)th or (i+1)th stone is present , then cost of removing the ith stone is a[i]. **** if neither (i-1)th nor (i+1)th stone is present , the cost of removing the ith stone is 0. **** Find the minimum total cost of removing all the stones. **** Constraints : 1 <= n <= 50000 1 <= a[i] , b[i] <= 1000

Теги dp

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский samadeep 2023-06-15 18:12:02 53
en1 Английский samadeep 2023-06-15 18:08:30 810 Initial revision (published)