Canadian Computing Olympiad: 2018 Day 2, Problem 2
You have a schedule of upcoming lectures that you have the option of attending. The lectures are numbered from to and are in chronological order. From the current schedule, you expect that the lecture will have quality . Since most of the lectures will be boring, you are only willing to attend some group of consecutive lectures. You will skip the remaining lectures so that you can catch up on sleep and participate in programming contests. Since you don't like taking notes, you will only be able to remember the content from of the lectures you attend. You want to choose the lectures you attend and the lectures you remember as to maximize the sum of the lecture qualities of those lectures.
There are changes that will be made to the schedule. The change to the schedule is represented by two values that indicate that the quality of the lecture changes to . For each of the versions of the schedule, find the maximum possible sum of lecture qualities that you can attain.
The first line will contain three integers , , and . The second line will contain integers . The next lines each contain two integers and .
For 5 of the 25 available marks, .
For an additional 10 of the 25 available marks, .
Output lines, each containing a single integer. The line that follows should contain the answer for the schedule obtained after the first changes are made.
4 3 1 6 1 2 4 1 3
Output for Sample Input
Explanation for Output for Sample Input
For the original schedule, it is best to attend the first three lectures and remember the first and third, for an overall value of . After the update, it is best to attend the last three lectures and remember the last two, giving a value of .