fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long minCost(vector<int>& a) {
  5. int n = a.size();
  6. sort(a.begin(), a.end());
  7. int med = a[n / 2];
  8. long long res = 0;
  9. for (int x : a) res += llabs(1LL * x - med);
  10. return res;
  11. }
  12.  
  13. long long countWays(vector<int>& a) {
  14. int n = a.size();
  15. sort(a.begin(), a.end());
  16. if (n % 2 == 1) return 1;
  17. return (long long)(a[n / 2] - a[n / 2 - 1] + 1);
  18. }
  19.  
  20. int main() {
  21. ios::sync_with_stdio(false);
  22. cin.tie(nullptr);
  23. int T; cin >> T;
  24. while (T--) {
  25. int N; cin >> N;
  26. vector<int> X(N), Y(N);
  27. for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
  28. long long S = minCost(X) + minCost(Y);
  29. long long K = countWays(X) * countWays(Y);
  30. cout << S << " " << K << "\n";
  31. }
  32. }
  33.  
Success #stdin #stdout 0.01s 5308KB
stdin
1
2
0 1
1 0
stdout
2 4