Huawei OD Computer Test Real Questions-Wonderland-2023 OD Unified Examination (Paper C)

Topic description :

Wonderland is a popular amusement park where Xiao Wang lives. Wonderland currently has four ticket sales methods, namely one-day ticket (1 day), three-day ticket (3 days), weekly ticket (7 days) and monthly ticket (30 days).

The price of each ticket sales method will be given by an array, and each ticket can be played without limit within the time limit on the ticket. For example, Xiao Wang bought a three-day ticket on the 10th day. Xiao Wang can play unlimited games on the 10th, 11th and 12th days. 

Xiao Wang plans to visit the amusement park several times in the next year. The travel dates planned by Xiao Wang will be given by an array. Now, please return the minimum consumption required to complete the travel plan based on the given ticket price array and Xiao Wang's planned travel date array.

Enter description:

Input is 2 arrays

The ticket price array is costs, costs.length=4, and the default order is one-day ticket, three-day ticket, weekly ticket and monthly ticket.


Xiao Wang’s planned play date array is days, 1<=days.length<=365, 1<=days[i]<=365, and the default order is ascending order.
 

Output description:

Minimum spending to complete the travel plan

Additional notes:

Sample description:

According to the information given by the ticket price array and the play date array, it is found that it is the most economical to buy a one-day ticket every time he goes to play, so Xiao Wang will buy 8 one-day tickets, each with a minimum cost of 5 yuan. It's 40 yuan.

Example 1

enter:

5 14 30 100
1 3 15 20 21 200 202 230

Output:

Guess you like

Origin blog.csdn.net/2301_76848549/article/details/135311214