#P4064. [JXOI2017] 加法

    ID: 3005 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>贪心2017二分各省省选树状数组优先队列

[JXOI2017] 加法

Description

Kelian has a positive integer sequence AA of length nn, but she feels the numbers in AA are too small, which makes her unhappy.

So she chooses mm intervals [li,ri][l_i,r_i] and two positive integers a,ka,k. She plans to select exactly kk intervals from these mm intervals, and perform one range add aa operation on each selected interval. (Each interval can be selected at most once).

Performing a +aa operation on a range [l,r][l,r] is defined as: for all ii[l,r][l,r], set AiA_i to Ai+aA_i+a. Now Kelian wants to know how to choose the intervals so that the minimum value of the sequence after the operations is as large as possible, i.e., maximize min{Ai}\min\{A_i\}.

Input Format

The first line contains an integer indicating the number of test cases.

For each test case, the first line contains four integers n,m,k,an,m,k,a.

The second line contains nn integers describing the sequence AA.

The next mm lines each contain two integers li,ril_i,r_i describing each interval. It is guaranteed that all intervals are pairwise distinct.

Output Format

For each test case, output one integer representing the maximum possible minimum value of the sequence after the operations.

1 
3 3 2 1
1 3 2
1 1
1 3
3 3
3

Hint

Choose to add 11 to intervals [1,1][1,1] and [1,3][1,3].

For 100%100\% of the testdata, it is guaranteed that 1n,m2×1051\leq\sum n,\sum m\leq 2\times 10^5, 1T2×1051\leq T\leq 2\times 10^5, 1km1\le k\le m, 1a1001\le a\le 100, 1Ai1081\le A_i\le 10^8.

Translated by ChatGPT 5