`package Test;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int midX = 0;
int midY = 0;
int[] x = new int[n];
int[] y = new int[n];
for (int i=0; i<n; i++){
x[i] = in.nextInt();
y[i] = in.nextInt();
}
quick_Sort(x, 0, n-1);
quick_Sort(y, 0, n-1);
midX = x[n/2];
midY = y[n/2];
System.out.println("超市的位置为:("+midX+","+midY+")");
int sum = 0;
for (int i = 0; i < n; i++) {
sum += Math.abs(x[i] - midX) + Math.abs(y[i] - midY);
}
System.out.println("距离和为:"+sum);
} //快速排序(挖坑法) public static void quick_Sort(int a[], int left, int right){ if (left >= right){ return; } int i = left; int j = right; int base = a[left]; while (i < j){ while (i < j && a[j] >= base){ j--; } if (i < j){ a[i++] = a[j]; } while (i <j && a[i] <= base){ i++; } if (i < j){ a[j--] = a[i]; } } a[i] = base; quick_Sort(a, left, i-1); quick_Sort(a, i+1, right); }
}
`