Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, a, b) for (ll i = a; i < b; i++)
#define pb emplace_back
#define allv v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
#define FASTio                                                                 \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define deb(x) cout << (#x) << " " << x << endl
ll mod = 1e9 + 7;
template <typename t> ll Max(ll a, ll b) { return (a > b) ? a : b; }
ll Min(ll a, ll b) { return (a > b) ? b : a; }
ll Power(ll a, ll b) {
  ll p = 1;
  a = a;
  b = b;
  while (b) {
    if (b & 1) {
      p = ((p) * (a));
    }
    a = ((a) * (a));
    b = (b / 2);
  }
  return p;
}
ll power(ll a, ll b) {
  if (b == 0)
    return 1;
  ll p = power(a, b / 2) % mod;
  p = (p * p) % mod;
  if (b & 1)
    p = (p * a) % mod;
  return p;
}
ll gcd(ll a, ll b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}
/*void dfs(ll i)
{
    visited[i]=true;
   // provinces.pb(i);
    for(auto it:adj[i])
    {
        if(!visited[it] && choices[it])
        dfs(it);
    }
}*/
ll prod(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<ll> x, y;
  ll n;
  cin >> n;
  ll a, b;
  rep(i, n) {
    cin >> a >> b;
    x.push_back(a + b);
    y.push_back(a - b);
  }
  ll r = *max_element(x.begin(), x.end());
  ll s = *min_element(x.begin(), x.end());
  ll u = *max_element(y.begin(), y.end());
  ll v = *min_element(y.begin(), y.end());
  cout << max(r - s, u - v) << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, a, b) for (ll i = a; i < b; i++)
#define pb emplace_back
#define allv v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
#define FASTio                                                                 \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define deb(x) cout << (#x) << " " << x << endl
ll mod = 1e9 + 7;
template <typename t> ll Max(ll a, ll b) { return (a > b) ? a : b; }
ll Min(ll a, ll b) { return (a > b) ? b : a; }
ll Power(ll a, ll b) {
  ll p = 1;
  a = a;
  b = b;
  while (b) {
    if (b & 1) {
      p = ((p) * (a));
    }
    a = ((a) * (a));
    b = (b / 2);
  }
  return p;
}
ll power(ll a, ll b) {
  if (b == 0)
    return 1;
  ll p = power(a, b / 2) % mod;
  p = (p * p) % mod;
  if (b & 1)
    p = (p * a) % mod;
  return p;
}
ll gcd(ll a, ll b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}
/*void dfs(ll i)
{
    visited[i]=true;
   // provinces.pb(i);
    for(auto it:adj[i])
    {
        if(!visited[it] && choices[it])
        dfs(it);
    }
}*/
ll prod(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  ll x[n], y[n];
  rep(i, n) cin >> x[i] >> y[i];
  ll dis = 0;
  for (ll i = 0; i < n; i++) {
    for (ll j = i + 1; j < n; j++) {
      if (dis < abs(x[j] - x[i]) + abs(y[j] - y[i]))
        dis = abs(x[j] - x[i]) + abs(y[j] - y[i]);
    }
  }
  cout << dis << endl;

  return 0;
}