#A. 畅游题河swim

    Type: Default File IO: swim 1000ms 512MiB

畅游题河swim

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.

题目描述

李尚道 和 张恒瑞 两个人在一条长长的河中游泳,这条河叫题河。

题河可以看成一条数轴,左端点坐标109-10^9,右端点坐标 10910^9

开始时,李尚道在点A,张恒瑞在点B。

题河中有 nn 个题目,每个题目看成一个点,第 ii 个要做的题目坐标为 tit_i

每道题目至少要被其中某一个人做一次。做题顺序不限。

问两人游泳的总距离最少是多少。

输入格式

第一行一个数字 TT 表示数据组数。

每组数据第一行三个整数 n,A,Bn, A, B,第二行 nn 个整数 t1,t2,...,tnt_1,t_2,...,t_n

保证所有 nn 之和不超过 21052*10^5

输出格式

一行一个整数。

4
7 -6 10
-15 -1 12 8 11 -6 0
2 -1000000000 -1000000000
1000000000 -1000000000
1 4 6
1
4 727 137
39 852 201 696
24
2000000000
3
413

数据范围

对于所有数据 1n2105,109A,B,ti1091\le n \le 2*10^5, -10^9 \le A,B,t_i \le 10^9

子任务1(16分):n20,106A,B,ti106n\le 20, -10^6 \le A,B, t_i \le 10^6

子任务2(36分):n5000,106A,B,ti106n\le 5000, -10^6 \le A,B,t_i \le 10^6

子任务3(21分):n5000n\le 5000

子任务4(27分)

CSP-S模拟赛

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2023-10-17 8:00
End at
2023-10-17 12:00
Duration
4 hour(s)
Host
Partic.
25