#P6717. [CCO 2018] Boring Lectures
[CCO 2018] Boring Lectures
Description
There is a sequence of length , where the -th number is .
There are modifications. In the -th modification, the number at position is changed to .
You need to find, for the initial sequence and after each modification, the maximum possible value of the sum of the largest and second largest elements among all consecutive subarrays of length .
Input Format
The first line contains three integers , as described above.
The second line contains integers , the sequence.
The next lines each contain two integers , representing one modification.
Output Format
Output lines. The -th line represents the answer after the -th modification. The first line represents the answer before any modifications.
4 3 1
6 1 2 4
1 3
8
6
Hint
Sample Explanation
For Sample .
- Before any modification, we choose , and the sum is .
- After the first modification, we choose , and the sum is .
Constraints
For of the testdata, , , , , , .
For of the testdata, .
For another of the testdata, .
Notes
Translated from Canadian Computing Olympiad 2018 Day 2 B Boring Lectures。
Translated by ChatGPT 5
京公网安备 11011102002149号