You want to buy a food subscription package for the upcoming month. You know exactly the days on which you will eat. This month has 30 days and there are 3 types of packages that available :
You want to pay as little as possible. You will be given a sorted (in increasing order) array A of dates when you will be eating. For example, given:
You can buy 7-Day and 1-day subscription. The two 1-day subscriptions should be used on days 29 and 30. The 7-day subscription should be used on the first seven days of the month. The total cost is 1097 and there is no other possible way of paying less.
Write a function:
function solution (A) { } that, given an array consisting of integers that specifies days on which you will eat, returns the minimum amount of money that you have to spend on food subscription for the month.
Input Format
An array of days where you would be eating.
Output Format
The minimum amount of money that you have to spend.
Constraints
You can buy 7-Day and 1-day subscription. The two 1-day subscriptions should be used on days 29 and 30. The 7-day subscription should be used on the first seven days of the month. The total cost is 1097 and there is no other possible way of paying less.