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

#include <bits/stdc++.h>

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc                                                            \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template <typename T> istream &operator>>(istream &is, vector<T> &v) {
  for (auto &it : v)
    is >> it;
  return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep = "";
  for (const auto &x : v)
    os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

void dbg_out() { cerr << "\\n"; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

void solve() {
  int n, x, y;
  cin >> n;
  vi diff[2];
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    diff[0].push_back(x + y);
    diff[1].push_back(x - y);
  }
  for (int i = 0; i < 2; ++i)
    sort(All(diff[i]));
  cout << max(diff[0].back() - diff[0][0], diff[1].back() - diff[1][0]) << "\\n";
}

int main() {
  Fast;
  // louisfghbvc{
  solve();
  //}
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc                                                            \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template <typename T> istream &operator>>(istream &is, vector<T> &v) {
  for (auto &it : v)
    is >> it;
  return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep = "";
  for (const auto &x : v)
    os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

void dbg_out() { cerr << "\\n"; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

struct p {
  LL x, y;
} arr[N];

int cross(p o, p a, p b) {
  return (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
}

int dis(p a, p b) { return abs(a.x - b.x) + abs(a.y - b.y); }

bool cmp(p a, p b) {
  int x = cross(arr[0], a, b);
  return x > 0 || (!x && dis(arr[0], a) > dis(arr[0], b));
}

vector<p> gg(int n) {
  vector<p> res(n);
  int k = 0;
  for (int i = 0; i < n; ++i) {
    while (k > 1 && (cross(res[k - 2], res[k - 1], arr[i]) <= 0))
      k--;
    res[k++] = arr[i];
  }
  res.resize(k);
  return res;
}

void solve() {
  int n;
  cin >> n;
  p mn = {(LL)1e9 + 5, (LL)1e9 + 5};
  int mni = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i].x >> arr[i].y;
    if (arr[i].x < mn.x && arr[i].y < mn.y) {
      mni = i;
      mn = arr[i];
    }
  }
  swap(arr[0], arr[mni]);
  sort(arr, arr + n, cmp);

  vector<p> res = gg(n);
  LL mx = LLONG_MIN;
  for (int i = 0; i < sz(res); ++i) {
    for (int j = i + 1; j < sz(res); ++j) {
      mx = max(mx, (LL)dis(res[i], res[j]));
    }
  }
  cout << mx << "\\n";
}

int main() {
  Fast;
  // louisfghbvc{
  solve();
  //}
  return 0;
}