#P4064. [JXOI2017] 加法
[JXOI2017] 加法
Description
Kelian has a positive integer sequence of length , but she feels the numbers in are too small, which makes her unhappy.
So she chooses intervals and two positive integers . She plans to select exactly intervals from these intervals, and perform one range add operation on each selected interval. (Each interval can be selected at most once).
Performing a + operation on a range is defined as: for all ∈ , set to . 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 .
Input Format
The first line contains an integer indicating the number of test cases.
For each test case, the first line contains four integers .
The second line contains integers describing the sequence .
The next lines each contain two integers 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 to intervals and .
For of the testdata, it is guaranteed that , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号