#P12354. 「HCOI-R2」秋殇别恋
「HCOI-R2」秋殇别恋
Description
Little fell into a deep sleep when he couldn't come up with a Problem A of the school mock competition. He dreamed of this problem:
There are two sequences with lengths of . For every , given the value of , The initial value of is . You need to execute the following commands times:
l r v: let . Then for every , .After executions, you need to output .
He found this problem very interesting, so he downloaded the data package and viewed it. However, due to the wake-up alarm on 6 o'clock, he forgot the value of and the relative order of the commands. But he knew that the of each command satisfies .
He decided to find a way to restore the data of this problem and make appropriate modifications to maximize the answer. The modification is about the arguments of the commands in the problem. He allows himself to perform up to operations as follows:
- Select and apply one of the four operations: , , , , where and denotes the parameters and in the -th command. After that, must be satisfied.
Find the maximum possible output of that problem after all the modifications.
For your convenience in completing this task, little kindly tells you a very useful property: All given intervals do not strictly contain each other before restoration (i.e. there is no such that ). You do not need to keep it during the modification.
Input Format
The first line contains three integers , which denote the sequence length, the number of commands, and the number of modifications respectively.
The second line contains integers, where the -th integer is .
On the next lines, the -th line contains two integers , which denotes the parameters of the -th command.
Output Format
A single integer which denotes the maximum output of that problem.
5 2 2
1 2 -3 -4 5
1 1
2 3
8
5 2 3
1 2 -3 -4 5
1 1
2 3
10
10 4 5
2 2 -3 -4 -5 1 2 -10 -9 -5
2 3
2 5
1 2
6 7
38
10 4 6
2 2 -3 -4 -5 1 2 -10 -9 -5
2 3
2 5
1 2
6 7
40
10 4 1000
2 2 -3 -4 -5 1 2 -10 -9 -5
2 3
2 5
1 2
6 7
43
Hint
Sample Description #1
- Move the interval to , which costs modifications;
- Execute the commands , and the maximum output is .
Sample Description #3
- Move the interval to , which costs modifications.
- Move the interval to , which costs modifications.
- Execute the commands , and the maximum output is .
Constraints
This problem uses subtasks.
| Subtask | Score | |||
|---|---|---|---|---|
| * | ||||
*: Subtask : Uses the sum instead of the minimum score. Each test cases is worth points. points for . points for .
For all test cases, it is guaranteed that , , ,.
For any , it is guaranteed that . There is no such that .
京公网安备 11011102002149号