PivotOJ

B Road Band

시간 제한: 4000ms메모리 제한: 1024MB출처: ICPC ECNA 2023-2024BOJ 30525

문제

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 \ref{samplefig} 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.

Figure B.1: Sample Input 1 showing placement of access points

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.

입력

There are three lines of input. The first line contains four integers mm, nn, kk, ss, where mm and nn (1m,n10001 \leq m,n \leq 1\,000) are the number of customers along each of the two roads, kk (1kmin(max(m,n),100)1 \leq k \leq \min(\max(m,n),100)) is the number of access points to be placed, and ss (1s501 \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 (0xi10000 \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 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 10510^{-5}.

예제

예제 1

입력
4 4 2 3
0.5 1.0 3.0 3.5
1.0 2.5 3.0 3.5
출력
18.86666667
코드를 제출하려면 로그인하세요.