CCC '19 S4 - Tourism

View as PDF

Points: 20 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem type
Canadian Computing Competition: 2019 Stage 1, Senior #4

You are planning a trip to visit tourist attractions. The attractions are numbered from to and must be visited in this order. You can visit at most attractions per day, and want to plan the trip to take the fewest number of days as possible.

Under these constraints, you want to find a schedule that has a nice balance between the attractions visited each day. To be precise, we assign a score to attraction . Given a schedule, each day is given a score equal to the maximum score of all attractions visited that day. Finally, the scores of each day are summed to give the total score of the schedule. What is the maximum possible total score of the schedule, using the fewest days possible?

Input Specification

The first line contains two space-separated integers and .

The next line contains space separated integers .

For 3 of the 15 available marks, .

For an additional 3 of the 15 available marks, and .

Output Specification

Output a single integer, the maximum possible total score.

Sample Input

5 3
2 5 7 1 4

Sample Output

12

Explanation of Output for Sample Input

We need to have at least two days to visit all the attractions, since we cannot visit all attractions in one day.

Visiting the first two attractions on day 1 will give a score of 5, and visiting the last three attractions on day 2 will give a score of 7, for a total score of 12.

Visiting three attractions on day 1, and two attractions on day 2, which is the only possibility to visit in the fewest number of days possible, would yield a total score of .

• commented on Feb. 4, 2022, 8:14 p.m. edited

Can you visit 0 attractions a day?

• commented on Feb. 4, 2022, 9:54 p.m.

Would that even matter?

• commented on Feb. 13, 2022, 7:42 p.m. edited

precisely. A solution with a day done nothing is equivalent to the optimal solution anyways, just as how adding 0 to a sum gives the sum anyways.

• commented on Feb. 2, 2022, 11:22 p.m.

What's more important, a higher score or a lower amount of days? Basically if you had a situation where you could get a higher score with more days or a lower score with less days, which would be the right answer?

• commented on Feb. 3, 2022, 3:17 a.m. edited

the lower amount of days. If a higher score is more important, then you should always just do days with all elements added together, which defeats the point of this problem.

• commented on Oct. 10, 2021, 10:53 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on May 8, 2021, 9:53 p.m. edit 2

Hi, I was thinking of using where it will tell you the highest score you could get in days with breaks along the way (where each break is when you could go on further that day but you could didn't, for example, you could go 4 but you only took 1 that day so that adds 3 breaks). To update the table I was thinking of using an RMQ. The complexity of this should be , not taking into account the RMQ, while using a little trick updating the table. Now I am stuck on the dumbest thing I can't find a way of doing an RMQ with potentially a million terms (maybe a sparse table? but I think that takes up too much space and maybe time)). SOOOO now I am just thinking my entire method is wrong, any hints? please.

• commented on Feb. 9, 2021, 5:13 a.m. edit 2

Hi, I've managed to get the first 6 points with a solution of complexity but I don't really see how I can get the last 9 points. Can someone help? How to it does not seem possible.

• commented on Feb. 9, 2021, 5:58 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Feb. 9, 2021, 11:14 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on July 23, 2020, 5:01 a.m.

Can an editorial be written for this problem?

• commented on July 23, 2020, 12:53 p.m.

• commented on Jan. 24, 2020, 4:41 a.m.

can i get a hint for the last 9 marks?

• commented on Jan. 14, 2020, 11:55 p.m.

Is this question sovlable with python? I see nobody got AC for this one, similar with senior Q5.

• commented on Feb. 26, 2019, 10:17 p.m.

cries

• commented on March 2, 2019, 1:13 a.m. edited

Poor boy who decided to skip S3 and focus on S4 :( I feel you.