|
||||||||||
Meeting point-1Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4185 Accepted Submission(s): 1453 Problem Description It has been ten years since TJU-ACM established. And in this year all the retired TJU-ACMers want to get together to celebrate the tenth anniversary. Because the retired TJU-ACMers may live in different places around the world, it may be hard to find out where to celebrate this meeting in order to minimize the sum travel time of all the retired TJU-ACMers. There is an infinite integer grid at which N retired TJU-ACMers have their houses on. They decide to unite at a common meeting place, which is someone's house. From any given cell, only 4 adjacent cells are reachable in 1 unit of time. Eg: (x,y) can be reached from (x-1,y), (x+1,y), (x, y-1), (x, y+1). Finding a common meeting place which minimizes the sum of the travel time of all the retired TJU-ACMers. Input The first line is an integer T represents there are T test cases. (0<T <=10) For each test case, the first line is an integer n represents there are n retired TJU-ACMers. (0<n<=100000), the following n lines each contains two integers x, y coordinate of the i-th TJU-ACMer. (-10^9 <= x,y <= 10^9) Output For each test case, output the minimal sum of travel times. Sample Input
Sample Output
Hint In the first case, the meeting point is (-1,-2); the second is (0,0), the third is (3,1) and the last is (-2,2) Author TJU Source | ||||||||||
|