fork(1) download
  1. #include<bits/stdc++.h>
  2. #include<fstream>
  3. using namespace std;
  4. ifstream fin("VNOICUP.INP");
  5. ofstream fout("VNOICUP.OUT");
  6. #define sz(a) (int)a.size()
  7. #define ll long long
  8. #define pb push_back
  9. #define forr(i, a, b) for(int i = a; i < b; i++)
  10. #define dorr(i, a, b) for(int i = a; i >= b; i--)
  11. #define ld long double
  12. #define vt vector
  13. #include<fstream>
  14. #define fi first
  15. #define se second
  16. #define pll pair<ll, ll>
  17. #define pii pair<int, int>
  18. const ld PI = 3.14159265359;
  19. using u128 = __uint128_t;
  20. //const int x[4] = {1, -1, 0, 0};
  21. //const int y[4] = {0, 0, 1, -1};
  22. const ll mod = 1e9 + 7;
  23. const int mxn = 1e5 + 5, mxq = 2e5 + 5, sq = 400, mxv = 15 * 10, pr = 31;
  24. const int base = (1 << 18);
  25. const ll inf = 2e9, neg = -69420, add = 1e9;
  26. int n;
  27. signed main(){
  28. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  29. cin >> n;
  30. vt<ll>a(n), b(n);
  31. for(int i = 0; i < n; i++){
  32. ll x, y; cin >> x >> y;
  33. a[i] = (x + y); b[i] = (x - y);
  34. }
  35. sort(a.begin(), a.end()); sort(b.begin(), b.end());
  36. ll ma = a[sz(a) / 2], mb = b[sz(b) / 2];
  37. ll ans = 0;
  38. for(int i = 0; i < sz(a); i++){
  39. //cout << a[i] << " ";
  40. ans += abs(a[i] - ma);
  41. }
  42. forr(i, 0, sz(b)){
  43. // cout << b[i] << " ";
  44. ans += abs(b[i] - mb);
  45. }
  46. assert(ans % 2 == 0);
  47. cout << ans / 2;
  48. }
  49.  
Runtime error #stdin #stdout 0.01s 5436KB
stdin
Standard input is empty
stdout
Standard output is empty