Tourism
Time limit1sMemory limit512 MB
Split the N attractions, in order, into the fewest days with at most K attractions per day, maximizing the sum of each day's highest score.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Greedy, Sliding window
- Solved
- No attempts yet
Problem
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 you want to finish the trip in as few days as possible.
Each attraction has a score . For a given schedule, each day scores the maximum score among the attractions visited that day. The total score of the schedule is the sum of the daily scores. Find the maximum total score among the schedules that use the fewest possible days.
Input
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
Output a single integer, the maximum possible total score.