UHCC1 P4 - Manhattan Distance
View as PDFFelim has  points with integer coordinates in the 
-plane that he received as a Valentine's gift, and he wants to find two distinct points 
 and 
 with integer coordinates such that the sum of the Manhattan distance between the 
 points and 
 and 
 is minimal.
He is unable to do so, so he wants you to find these two points and output the minimum distance.
The Manhattan distance between  and 
 is 
.
Constraints
Input Specification
The first line contains the integer . The next 
 lines each contain 2 integers, 
.
Output Specification
The first and only line contains the minimum sum of the Manhattan distance from the  points to the two points you selected.
Sample Input
4
3 1
5 1
1 3
5 4
Sample Output
22
Explanation for Sample
If we choose the two points to be  and 
, then the sum of distances is 
. It can be proven that this is minimal.
Comments