Question 1 Revisit Later C++ How to Attempt? Joy Rides Alice is in an amusement park,…
- User
Question 1 Revisit Later C++ How to Attempt? Joy Rides Alice is in an amusement park, where there are N rides, each costing some bounties. In order to go on the rides, she needs to follow a sequence, ie, first she should take ride 1. then 2, and so on up till N There exists a small hack that if a person pays the bounty for ride, then s/he has the option of taking the nest 7 number of rides for free. Le., if a person has paid for ride number 2, s/he has the option of taking ride number 3 and 4 free of cost along with ride 2. Alice wants to spend a minimum number of bounties to take all the rides. Your task is to help Alice find and return the minimum bounties that need to be paid in order for her to take all the rides. Input Specification: input1: An integer N, denoting the number of joy rides. input2: An integer array of size N, representing the bounties required for each ride. Output Specification: Return an integer value representing the minimum number of bounties required to take all the joy rides. Example 1:Example 1: input1:5 input2: (4.2.9.1.7) Output: 7 Explanation: Alice pays 4 bounties for ride 1 and has the option of taking the next ride for free. In order to spend the minimum number of bounties, she chooses to pay for the second ride. Now she can either take ride 3 and 4 for free and spend a total of 4+2+7 = 13 bounties or she can take ride 3 for free and pay for ride 4 so that she can take ride 5 for free by spending 4+2+1 = 7 bounties. Since 7 is less than 11, 7 is returned as the output. Example 2: input1: 4 input2: (5.8.7.6) Output: 12 Explanation: Alice pays 5 and 7 bounties for rides 1 and 3 respectively and takes ride 2 and 4 for free. She completes all the rides in 5 + 7 = 12 bounties. Therefore, 12 is returned as the output write c++ code
- Assistant