#P17368. [ECNA 2023] B Road Band

    ID: 19786 远端评测题 4000ms 2048MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>2023Special JudgeICPC

[ECNA 2023] B Road Band

Problem Description

All the residents of the rural community of Axes Point live on one of two parallel streets separated by a band of green park land. Recently, the local board of supervisors received a grant to (finally) bring wireless service to the town. The grant provides enough money for them to install kk access points, and the supervisors have decided to place them in a straight line on County Road "B," which lies in the wooded band midway between the two residential streets. They want to place them in a way that minimizes the distance between users and their nearest access point. Specifically, they want to minimize the sum of the squares of the distances of each user from their nearest access point. For instance, Figure 1 shows two streets with eight customers and their locations along the streets (this is the first sample input). The streets are 33 units apart, and two access points have been placed at points midway between the two streets so that the sum of the eight squared distances is minimized.

Given the locations of all customers along each of the two streets, the distance between the streets, and the number of access points, help the local government determine the minimum sum of squared distances that can be achieved.

:::align{center} :::

Input Format

There are three lines of input. The first line contains four integers mm, nn, kk, ss, where mm and nn (1≤m,n≤1 0001 \leq m,n \leq 1\,000) are the number of customers along each of the two roads, kk (1≤k≤min⁡(max⁡(m,n),100)1 \leq k \leq \min(\max(m,n),100)) is the number of access points to be placed, and ss (1≤s≤501 \leq s \leq 50) is the distance separating the two roads. The second line contains mm floating-point values x1,x2,⋯ ,xmx_1, x_2, \cdots, x_m (0≤xi≤1 0000 \leq x_i \leq 1\,000) giving the locations of the mm customers along the first road. The third line is similar, containing nn floating-point locations of customers along the second road. All values on each of the second and third lines will be distinct (but some values may appear in both lines). Customer locations will have no more than four decimal places.

Output Format

Output a single floating-point value equal to the minimum sum of squared distances for each customer from the closest of the kk access points. Answers should be correct to within an absolute or relative error of 10−510^{-5}.

4 4 2 3
0.5 1.0 3.0 3.5
1.0 2.5 3.0 3.5
18.86666667