here is the question
there are n shops in a row. You have a number of coins to spend while
shopping. These coins are denoted by c1,c2,…cn where Ci is the number of
coins that you have to spend when you shop at the ith shop.
you start shopping from the very first shop and move towards the nth shop sequentially
For every shop that you skip, you have to buy one candy. Each candy costs x coins. You cannot skip
more than three shops in a row. Also you cannot skip first and last shop.
your task is to determine the minimum number of coins that you have spent after shopping
from the nth shop.
2<= n <= 2x10^5
1<= x , Ci <= 2x10^5
If you know any similar questions like this please mention the links.