Man score 10000
Shops and candies
There are n shops in a row. You have a number of coins to spend while shopping. These coins are denoted by C1,C2...
the number of coins that you have to spend when you shop at the
Cn where is
ith
shop.
You start shopping from the very first shop and move towards then
th
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 the first and last shop.
Your task is to determine the minimum number of coins that you have spent after shopping from the n'
nth
shop.
Input format
• The first line consists of two integer n and x denoting the number of shops and the cost of a single candy.
• The next line contains n space-separated integers representing the number of coins that you spend in shops 1 to n respectively.
Output format
Print a single value that is equal to the minimum number of coins that you have spent.
Answers
Answer:
Man score 10000 Shops and candies There are n shops in a row. You have a number of coins to spend while shopping. These coins are denoted by C1,C2... the number of coins that you have to spend when you shop at the Cn where is the shop. You start shopping from the very first shop and move towards then th 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 the first and last shop. Your task is to determine the minimum number of coins that you have spent after shopping from the n' nth shop. Input format • The first line consists of two integer n and x denoting the number of shops and the cost of a single candy. • The next line contains n space-separated integers representing the number of coins that you spend in shops 1 to n respectively. Output format Print a single value that is equal to the minimum number of coins that you have spent.
Explanation:
pls mark me as brainlist