Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
// #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i, b, a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout << "debug... " << n1 << "\\n"
const ll INF = (1ll << 60) - 1; // ll ans = 3e18 + 5;
////////////////////////////////////////////////////////
class abc {
public:
  ll x;
  ll y;
};
bool fun1(abc &a, abc &b) {
  return (a.x - b.x) - (a.y - b.y) < (b.x - a.x) - (b.y - a.y);
}
// bool fun2( abc &a , abc &b )
// {
//     return a.x-a.y < b.x-b.y ;
// }
// bool fun3( abc &a , abc &b )
// {
//     return -a.x-a.y < -b.x-b.y ;
// }
// bool fun4( abc &a , abc &b )
// {
//     return -a.x-+a.y < -b.x+b.y ;
// }
////////////////////////////////////////////////////////
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll tc = 1;
  // cin>>tc;
  while (tc--) {
    ll n;
    cin >> n;
    abc a[n];
    ll ans = -1e12;
    ll mx1 = -1e12;
    ll mn1 = 1e12;
    ll mx2 = -1e12;
    ll mn2 = 1e12;
    ll mx3 = -1e12;
    ll mn3 = 1e12;
    ll mx4 = -1e12;
    ll mn4 = 1e12;
    rep(i, 0, n) {
      cin >> a[i].x >> a[i].y;

      mx1 = max(mx1, a[i].x + a[i].y);
      mn1 = min(mn1, a[i].x + a[i].y);

      mx2 = max(mx2, a[i].x - a[i].y);
      mn2 = min(mn2, a[i].x - a[i].y);
      // ans=max({mx1-mx2,abs(mx2+mx3),abs(mn2+mn3)});
      ans = max({ans, mx1 - mn1, mx2 - mn2, mn2 - mx2, mn1 - mx1});
    }

    cout << ans;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
// #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i, b, a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout << "debug... " << n1 << "\\n"
const ll INF = (1ll << 60) - 1; // ll ans = 3e18 + 5;
////////////////////////////////////////////////////////
class abc {
public:
  ll x;
  ll y;
};
bool fun1(abc &a, abc &b) { return a.x + a.y < b.x + b.y; }
bool fun2(abc &a, abc &b) { return a.x - a.y < b.x - b.y; }
bool fun3(abc &a, abc &b) { return -a.x - a.y < -b.x - b.y; }
bool fun4(abc &a, abc &b) { return -a.x - +a.y < -b.x + b.y; }
////////////////////////////////////////////////////////
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll tc = 1;
  // cin>>tc;
  while (tc--) {
    ll n;
    cin >> n;
    abc a[n];
    rep(i, 0, n) { cin >> a[i].x >> a[i].y; }
    sort(a, a + n, fun1);
    ll ans = abs(a[0].x - a[n - 1].x) + abs(a[0].y - a[n - 1].y);
    sort(a, a + n, fun2);
    ans = max(ans, abs(a[0].x - a[n - 1].x) + abs(a[0].y - a[n - 1].y));
    sort(a, a + n, fun3);
    ans = max(ans, abs(a[0].x - a[n - 1].x) + abs(a[0].y - a[n - 1].y));
    sort(a, a + n, fun4);
    ans = max(ans, abs(a[0].x - a[n - 1].x) + abs(a[0].y - a[n - 1].y));
    cout << ans;
  }
}