Problem p02805 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target("sse4.2")
using namespace std;
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
#define time                                                                   \
  cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
lli maxSubArraySum(lli a[], lli size) {
  lli max_so_far = INT_MIN, max_ending_here = 0;

  for (lli i = 0; i < size; i++) {
    max_ending_here = max_ending_here + a[i];
    if (max_so_far < max_ending_here)
      max_so_far = max_ending_here;

    if (max_ending_here < 0)
      max_ending_here = 0;
  }
  return max_so_far;
}
int main() {

  fast;
  lli n;
  cin >> n;
  lli a[n][2];
  double x = 0, y = 0;
  for (lli i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
    x += a[i][0], y += a[i][1];
  }
  double X = x / n, Y = y / n;
  // cout<<X<<" "<<Y<<"\n";
  double m = 0.999;
  double p = 0.01;
  lli f;
  double dist = 0;
  for (lli i = 1; i <= 10000000; i++) {
    f = 0;
    dist = ((X - a[0][0]) * (X - a[0][0]) + (Y - a[0][1]) * (Y - a[0][1]));
    for (lli j = 1; j < n; j++) {
      if (((X - a[j][0]) * (X - a[j][0]) + (Y - a[j][1]) * (Y - a[j][1])) >
          dist) {
        dist = ((X - a[j][0]) * (X - a[j][0]) + (Y - a[j][1]) * (Y - a[j][1]));
        f = j;
      }
    }
    X += (a[f][0] - X) * p;
    Y += (a[f][1] - Y) * p;
    p *= m;
  }

  cout << fixed << setprecision(9)
       << sqrt((X - a[f][0]) * (X - a[f][0]) + (Y - a[f][1]) * (Y - a[f][1]));

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target("sse4.2")
using namespace std;
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
#define time                                                                   \
  cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
lli maxSubArraySum(lli a[], lli size) {
  lli max_so_far = INT_MIN, max_ending_here = 0;

  for (lli i = 0; i < size; i++) {
    max_ending_here = max_ending_here + a[i];
    if (max_so_far < max_ending_here)
      max_so_far = max_ending_here;

    if (max_ending_here < 0)
      max_ending_here = 0;
  }
  return max_so_far;
}
int main() {

  fast;
  lli n;
  cin >> n;
  lli a[n][2];
  double x = 0, y = 0;
  for (lli i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
    x += a[i][0], y += a[i][1];
  }
  double X = x / n, Y = y / n;
  // cout<<X<<" "<<Y<<"\n";
  double m = 0.999;
  double p = 0.01;
  lli f;
  double dist = 0;
  for (lli i = 1; i <= 8000000; i++) {
    f = 0;
    dist = ((X - a[0][0]) * (X - a[0][0]) + (Y - a[0][1]) * (Y - a[0][1]));
    for (lli j = 1; j < n; j++) {
      if (((X - a[j][0]) * (X - a[j][0]) + (Y - a[j][1]) * (Y - a[j][1])) >
          dist) {
        dist = ((X - a[j][0]) * (X - a[j][0]) + (Y - a[j][1]) * (Y - a[j][1]));
        f = j;
      }
    }
    X += (a[f][0] - X) * p;
    Y += (a[f][1] - Y) * p;
    p *= m;
  }

  cout << fixed << setprecision(9)
       << sqrt((X - a[f][0]) * (X - a[f][0]) + (Y - a[f][1]) * (Y - a[f][1]));

  return 0;
}