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

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
#define pr priority_queue
ll maxn = 100000;
vector<ll> v;
void sieve() {
  vector<bool> is(maxn, true);
  for (ll i = 4; i < maxn; i += 2)
    is[i] = false;
  for (ll i = 3; i * i < maxn; i++) {
    if (is[i]) {
      for (ll j = i * i; j < maxn; j += i)
        is[j] = false;
    }
  }
  for (ll i = 2; i < maxn; i++) {
    if (is[i])
      v.push_back(i);
  }
  return;
}
vector<ll> spf(maxn);
void prime() {
  for (ll i = 1; i < maxn; i++)
    spf[i] = i;
  for (ll i = 4; i < maxn; i += 2)
    spf[i] = 2;
  for (ll i = 3; i * i < maxn; i++) {
    if (spf[i] == i) {
      for (ll j = i * i; j < maxn; j += i)
        if (spf[j] == j)
          spf[j] = i;
    }
  }
  return;
}
vector<ll> get(ll x) {
  vector<ll> ftrs;
  while (x != 1) {
    ftrs.push_back(spf[x]);
    x = x / spf[x];
  }
  return ftrs;
}
bool comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  if (a.fi > b.fi)
    return false;
  else if (a.fi == b.fi) {
    if (a.sec > b.sec)
      return false;
  }
  return true;
}
bool comp1(pair<ll, ll> &a, pair<ll, ll> &b) {
  if (a.fi > b.fi)
    return false;
  else if (a.fi == b.fi) {
    if (a.sec < b.sec)
      return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  ll miny = LLONG_MAX, maxy = LLONG_MIN;
  ll miny1 = LLONG_MAX, maxy1 = LLONG_MIN;
  for (ll i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    miny = min(miny, x + y);
    maxy = max(maxy, x + y);
    miny1 = min(miny1, x - y);
    maxy1 = max(maxy1, x - y);
  }
  ll ans1 = abs(maxy - miny);
  ll ans2 = abs(maxy1 - miny1);
  ll ans = max(ans1, ans2);
  cout << ans << "\\n";
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
#define pr priority_queue
ll maxn = 100000;
vector<ll> v;
void sieve() {
  vector<bool> is(maxn, true);
  for (ll i = 4; i < maxn; i += 2)
    is[i] = false;
  for (ll i = 3; i * i < maxn; i++) {
    if (is[i]) {
      for (ll j = i * i; j < maxn; j += i)
        is[j] = false;
    }
  }
  for (ll i = 2; i < maxn; i++) {
    if (is[i])
      v.push_back(i);
  }
  return;
}
vector<ll> spf(maxn);
void prime() {
  for (ll i = 1; i < maxn; i++)
    spf[i] = i;
  for (ll i = 4; i < maxn; i += 2)
    spf[i] = 2;
  for (ll i = 3; i * i < maxn; i++) {
    if (spf[i] == i) {
      for (ll j = i * i; j < maxn; j += i)
        if (spf[j] == j)
          spf[j] = i;
    }
  }
  return;
}
vector<ll> get(ll x) {
  vector<ll> ftrs;
  while (x != 1) {
    ftrs.push_back(spf[x]);
    x = x / spf[x];
  }
  return ftrs;
}
bool comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  if (a.fi > b.fi)
    return false;
  else if (a.fi == b.fi) {
    if (a.sec > b.sec)
      return false;
  }
  return true;
}
bool comp2(pair<ll, ll> &a, pair<ll, ll> &b) {
  if (a.sec > b.sec)
    return false;
  else if (a.sec == b.sec) {
    if (a.fi > b.fi)
      return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  vector<pair<ll, ll>> vec1, vec2;
  for (ll i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    vec1.push_back({x, y});
    vec2.push_back({x, y});
  }
  sort(vec1.begin(), vec1.end(), comp);
  sort(vec2.begin(), vec2.end(), comp2);
  ll ans1 =
      abs(vec1[0].fi - vec1[n - 1].fi) + abs(vec1[0].sec - vec1[n - 1].sec);
  ll ans2 =
      abs(vec2[0].fi - vec2[n - 1].fi) + abs(vec2[0].sec - vec2[n - 1].sec);
  ll ans = max(ans1, ans2);
  cout << ans << "\\n";
  return 0;
}