#P12354. 「HCOI-R2」秋殇别恋

    ID: 11725 远端评测题 2500ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DP洛谷原创O2优化洛谷月赛

「HCOI-R2」秋殇别恋

Description

Little ζ\zeta 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 a,b a,b with lengths of n n . For every 1in 1 \le i \le n , given the value of aia_i, The initial value of bi b_i is 0 0 . You need to execute the following commands m m times:

  • l r v: let v=v(1maxi=lrbi) v'=v(1-\max_{i=l}^r|b_i|) . Then for every lir l \le i \le r , bibi+v b_i \leftarrow b_i+v' .

After m m executions, you need to output i=1naibi \sum_{i=1}^na_ib_i .

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 v v and the relative order of the commands. But he knew that the v v of each command satisfies v{1,1} v\in\{-1,1\} .

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 k k operations as follows:

  • Select 1im 1 \le i \le m and apply one of the four operations: lili1 l_i \leftarrow l_i-1 , lili+1 l_i \leftarrow l_i+1 , riri1 r_i \leftarrow r_i-1 , riri+1r_i \leftarrow r_i+1 , where lil_i and rir_i denotes the parameters ll and rr in the ii-th command. After that, 1lirin 1 \le l_i \le r_i \le n must be satisfied.

Find the maximum possible output of that problem after all the modifications.

For your convenience in completing this task, little ζ \zeta kindly tells you a very useful property: All given intervals do not strictly contain each other before restoration (i.e. there is no 1i,jm 1 \le i,j \le m such that li<ljrj<ri l_i<l_j \le r_j<r_i ). You do not need to keep it during the modification.

Input Format

The first line contains three integers n,m,kn,m,k, which denote the sequence length, the number of commands, and the number of modifications respectively.

The second line contains n n integers, where the ii-th integer is ai a_i .

On the next m m lines, the i i -th line contains two integers li,ri l_i, r_i , which denotes the parameters of the i i -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 [2,3] [2,3] to [3,4] [3,4] , which costs 2 2 modifications;
  • Execute the commands (3,4,1),(1,1,1)(3,4, -1),(1,1,1) , and the maximum output is 8 8 .

Sample Description #3

  • Move the interval [2,5][2,5] to [3,5] [3,5] , which costs 1 1 modifications.
  • Move the interval [6,7] [6,7] to [7,10] [7,10] , which costs 4 4 modifications.
  • Execute the commands (3,5,1),(2,3,1),(1,2,1),(7,10,1) (3,5, -1),(2,3,1),(1,2,1),(7,10,-1) , and the maximum output is 38 38 .

Constraints

This problem uses subtasks.

Subtask n n \le m m \le k k \le Score
0 0 10 10 5 5 10 10
1 1 103 10^3 100 100 1 1 15 15 *
2 2 20 20 5 5 20 20 15 15
3 3 100 100 10 10 100 100 30 30
4 4 103 10^3 100 100 103 10^3

*: Subtask 11: Uses the sum instead of the minimum score. Each test cases is worth 55 points. 55 points for k=0 k=0 . 1010 points for k=1k=1.

For all test cases, it is guaranteed that 1n1000 1 \le n \le 1000 , 1m100 1 \le m \le 100 , 0k1000 0 \le k \le 1000 0ai106 0 \le |a_i| \le 10^6 .

For any 1im 1 \le i \le m , it is guaranteed that 1lirin 1 \le l_i \le r_i \le n . There is no 1i,jm 1 \le i,j \le m such that li<ljrj<ri l_i<l_j\le r_j<r_i .