Scrooge.net
시간 제한1초메모리 제한1024 MB
주어진 직선 위에서 k개 집까지의 유클리드 거리 합을 최소로 만드는 점을 찾는다.
문제
In the Scrooge Village they have finally got Internet access. Well, sort of... Direct cable line was routed across the village and into the city nearby. The villagers were proud of the fact that the Internet was finally available in the village and decided to get connected. The provider made a decision to install only one connection gate but let the villagers choose the point of connection. Naturally, the scroogers wanted to have all houses connected to the network and save as much as possible on the wiring. It was decided that the communication wires are to be stretched from each house to the connection point no matter how complicated the mounting was.
Knowing each house location it is required to find a point on the cable line, which makes the total distance to all the houses minimal.
입력
First line contains two pairs of integers , , , () --- the Cartesian coordinates of two different points located on the cable line. Second line contains integer () --- the number of houses. Following lines contain two integers each , () --- -th house coordinates.
출력
Write the total wire length needed and coordinates of the connection point. If there are several such points, output any. The answer is considered to be correct if absolute or relative error does not exceed .