#P17550. [JAG 2026 Summer Camp #2] Buttons
[JAG 2026 Summer Camp #2] Buttons
Problem Description
Consider a sequence of length . Initially, all elements of are zero. You are also given a sequence of nonnegative integers.
There are buttons. Pressing the -th button once increases by for every integer satisfying . Each button may be pressed any number of times, including zero.
The buttons must be pressed so that, for every , the final value of is at most .
Find the maximum possible value of
among all valid ways of pressing the buttons.
Input Format
The input contains one or more test cases. The first line of the input contains an integer (), which is the number of test cases. The descriptions of the test cases follow, each in the following format.
N M K
P_1 P_2 ... P_N
L_1 R_1
...
L_M R_M
The first line of each test case contains three integers , , and , representing the length of the sequence , the number of buttons, and the upper bound for each element of , respectively. They satisfy .
The second line contains integers . For each (), the integer represents the weight of and satisfies .
Each of the following lines contains two integers and (). They satisfy and represent the interval affected by the -th button.
The sum of , , and over all test cases does not exceed each.
Output Format
Output lines. For each test case, output the maximum possible value of among all valid ways of pressing the buttons, in a separate line.
3
4 3 2
3 1 4 2
1 2
2 3
4 4
1 3 5
7
1 1
1 1
1 1
12 7 1
5 0 8 2 7 1 6 3 9 4 0 10
1 3
2 5
4 6
6 8
9 12
3 7
8 10
14
35
50
Hint
In the first test case, pressing the second and third buttons twice each results in . The resulting sum is then , which is the maximum possible value.