2 3 1 1 2 1 1 2 5 2 9 5 20 11 9 1 1 1 20
2 44
#include <stdio.h> #include <algorithm> using namespace std; int x[21], y[21]; int main(){ int t, n, a, b, sum; scanf("%d", &t); while(t--){ scanf("%d", &n); for(int i = 0; i < n; ++i){ scanf("%d%d", &x[i], &y[i]); } sort(x, x + n); sort(y, y + n); a = x[n/2]; b = y[n/2]; sum = 0; for(int i = 0; i < n; ++i) sum += abs(x[i] - a) + abs(y[i] - b); printf("%d\n", sum); } return 0; }