#A. 新能源汽车(car)

    Type: Default 1000ms 256MiB

新能源汽车(car)

No testdata at current.

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

巡有一辆新能源汽车,汽车有 nn 个电池,每个电池能最多储存 aia_i 的单位电。每个电池的每一单位电能移动一单位距离,巡能指定每一个单位由哪个电池供应。

巡从原点出发,巡只能往前走。有 mm 个加油站,距离原点 xix_i 的地方有加油站,能把 tit_i 号电池的点充满。

当汽车所有电池都没电了,就不能动了。请告诉巡他最多能走多少单位的距离。

输入格式

第一行一个正整数 TT 表示测试数据数量。

每个测试点第一行两个正整数表示 n,mn,m

接下来一行 nn 个正整数表示 a1,a2,,ana_1,a_2,\dots,a_n

接下来 mm 行,每行两个正整数表示 xi,yix_i,y_i

输出格式

TT 行,每行一个正整数表示答案。

样例

【样例输入】

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

【样例输出】

12
9

数据范围

对所有数据 1T101\leq T\leq 101n,m2×1051\leq n,m\leq 2\times 10^5

测试点编号 n,mn,m\leq 特殊性质
11 1010
22 100100
33 2×1052\times 10^5 \checkmark
44

特殊性质:ai=1a_i=1

NOIP 模拟赛(十)

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2024-11-7 7:45
End at
2024-11-7 12:15
Duration
4.5 hour(s)
Host
Partic.
10