logo AlgoBeat OnlineJudge
登录 注册

#217800. [JAG 2026 Summer Camp #2] Buttons

内存限制:2048 MiB 时间限制:4000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

输入格式

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 lines. For each test case, output the maximum possible value of among all valid ways of pressing the buttons, in a separate line.

样例

样例输入 1

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

样例输出 1

14
35
50

数据范围与提示

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.