아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Wiring

시간 제한1초메모리 제한512 MB

요약
직선 위의 빨강 점과 파랑 점을 이어 모든 점이 반대 색과 연결되도록 하면서 전체 전선 길이의 합을 최소로 만든다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 동적 계획법
정답자
아직 제출이 없습니다

문제

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:

  1. Each connection point has at least one wire to a connection point of a different color.
  2. The total length of the wires is minimized.

제한

  • 1≤n,m≤100,0001 \leq n, m \leq 100\\,000,
  • 0≤r\[i]≤1090 \leq r\[i] \leq 10^9 (for all 0≤i≤n−10 \leq i \leq n-1),
  • 0≤b\[i]≤1090 \leq b\[i] \leq 10^9 (for all 0≤i≤m−10 \leq i \leq m-1),
  • Each of the arrays rr and bb is sorted in ascending order.
  • All n+mn+m values in the arrays rr and bb are distinct.

예제

이 문제는 공개된 예제가 없습니다.