Wiring
시간 제한1초메모리 제한512 MB
직선 위의 빨강 점과 파랑 점을 이어 모든 점이 반대 색과 연결되도록 하면서 전체 전선 길이의 합을 최소로 만든다.
문제
Maryam is an electrical engineer. She is designing wiring on a communication tower. On the tower there are some connection points, placed at distinct heights. A wire can be used to connect any two connection points. Each connection point can be connected to an arbitrary number of wires. There are two types of connection points: red and blue.
For the purpose of this problem the tower should be viewed as a line and the connection points as blue and red points that are at non-negative integer coordinates on this line. The length of a wire is the distance between the two connection points it connects.
Your goal is to help Maryam find a wiring scheme such that:
- Each connection point has at least one wire to a connection point of a different color.
- The total length of the wires is minimized.
제한
- ,
- (for all ),
- (for all ),
- Each of the arrays and is sorted in ascending order.
- All values in the arrays and are distinct.
예제
이 문제는 공개된 예제가 없습니다.