A. 连线问题

    Type: Default 1000ms 256MiB

连线问题

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.

连线问题

Description

在二维平面上,直线 y=Ay=A上有 NN个点,坐标为 (a[1...n],A)(a[1...n],A) 直线y=by=b上有m个点,坐标为(b[1...m],B)(b[1...m],B); 任意两点之间连线的代价为它们的欧几里得距离 dis=sqrt((x1x2)2+y1y2)2)dis=sqrt((x_{1}-x_{2})^{2}+y_{1}-y_{2})^{2}) 现在你想把这 {n+m}l联通(任意两点间有路径),求最小总代价

Format

输入格式

第一行四个整数n,m,a,bn,m,a,b 第二行nn个整数da[1...n]da[1...n],为aa的差分数组(即距离上一个点的距离) 第二行mm个整数db[1...n]db[1...n],为bb的差分数组

输出格式

输出一个小数,代表最小总代价,保留小数点后2位

样例

2 3 1 3
1 2
2 2 
7.24
10 10 10 1000
1 2000000 10 10 10 10 10 10 10 1
1000006 1000000 10 10 10 10 10 10 10 10
2001141.99
7 6 1 3
1 2 1 3 3 9 2
8 5 1 2 5 4
29.28
7 6 6 3
1 2 1 3 3 9 2
1 5 1 8 5 4
35.99

数据范围

对于 10% 的数据,n,m10n,m \leq 10 对于 40% 的数据,n,m103n,m \leq 10^{3} 对于 70% 的数据,n,m105n,m \leq 10^{5} 对于 100% 的数据,n,m6105n,m \leq 6*10^{5},1a[i],b[i]1081 \leq a[i],b[i] \leq 10^{8}, 1A,B20001 \leq A,B \leq 2000

test

Not Attended
Status
Done
Rule
OI
Problem
1
Start at
2025-8-4 21:00
End at
2025-8-4 23:00
Duration
2 hour(s)
Host
Partic.
0