| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Network Connection
Description There are M network interfaces in the wall of aisle of library. And N
computers next to the wall need to be connected to the network. A
network interface can only connect with one computer at most. To
connect an interface with coordinate x with a computer with coordinate y needs |x - y| unit of length of network cable. Your task is to minimize the total length of network cables to be used. Input The first line contains two integers M (1 ≤ M ≤ 100000), N (1 ≤ N ≤ 2000, N ≤ M). The following M + N lines each contains a integer coordinate. The first M coordinates are corresponding to the network interfaces, and the next N
ones corresponding to the computers. All coordinates are arranged in
[0, 1000000]. Distinct interfaces may have the same coordinate, so do
the computers. Output Print an integer, representing minimum length of network cables to be used. Sample Input Sample Output Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2007 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator