Problem:
Diameter of a Convex Polygon

Find the diameter of a convex polygon g. In other words, find a pair of points that have maximum distance between them.

Input

n
x1 y1
x2 y2
:
xn yn

The first integer n is the number of points in g.

In the following lines, the coordinate of the i-th point pi is given by two real numbers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them. Each value is a real number with at most 6 digits after the decimal point.

Output

Print the diameter of g in a line. The output values should be in a decimal fraction with an error less than 0.000001.

Constraints

3 ≤ n ≤ 80000

-100 ≤ xi, yi ≤ 100

No point in the g will occur more than once.

Sample Input 1

3
0.0 0.0
4.0 0.0
2.0 2.0

Sample Output 1

4.00

Sample Input 2

4
0.0 0.0
1.0 0.0
1.0 1.0
0.0 1.0

Sample Output 2

1.414213562373

Solution in C++14 (judge verdict: Accepted)

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class Vec;
Vec operator/(const Vec& v, const double& divisor);
Vec operator*(const double& scale, const Vec& v);

class Vec {
  using F = double;
  vector<F> container;

 public:
  Vec(size_t size) : container(size) {}
  Vec(initializer_list<F> elements)
      : container(elements.begin(), elements.end()) {}
  size_t dim() const { return container.size(); }
  F& operator[](const size_t size) { return container.at(size); }
  const F& operator[](const size_t size) const { return container.at(size); }
  Vec operator+(const Vec& other) const {
    Vec ret(*this);
    for (size_t i = 0; i < dim(); i++) ret[i] += other[i];
    return ret;
  }
  Vec operator-(const Vec& other) const { return (*this) + (-other); }
  Vec operator-() const { return -1.0 * (*this); }
  F inner(const Vec& other) const {
    F acc = 0;
    for (size_t i = 0; i < dim(); i++) {
      acc += (*this)[i] * other[i];
    }
    return acc;
  }
  F norm() const { return sqrt(inner(*this)); }
  Vec unit() const { return (*this) / this->norm(); }
  F ccw(const Vec& other) const {
    return (*this)[0] * other[1] - other[0] * (*this)[1];
  }
  Vec normal() const { return Vec({-(*this)[1], (*this)[0]}); }
};
Vec operator/(const Vec& v, const double& divisor) { return 1.0 / divisor * v; }
Vec operator*(const double& scale, const Vec& v) {
  Vec ret(v);
  for (size_t i = 0; i < ret.dim(); i++) ret[i] *= scale;
  return ret;
}

class Convex {
  const vector<Vec>& m_points;
  vector<int> m_hull;

 public:
  Convex(const vector<Vec>& points) : m_points(points), m_hull() {
    const size_t n = m_points.size();

    vector<int> idx(n);
    for (size_t i = 0; i < n; i++) idx[i] = i;
    sort(idx.begin(), idx.end(), [&](const int& lh, const int& rh) {
      if (m_points[lh][0] == m_points[rh][0]) {
        return m_points[lh][1] < m_points[rh][1];
      }
      return m_points[lh][0] < m_points[rh][0];
    });

    vector<int> conv[2];
    double si = 1;
    for (int j = 0; j < 2; j++) {
      vector<int>& cv = conv[j];
      for (size_t i = 0; i < n; i++) {
        const int k = idx[i];
        const Vec& c = m_points[k];
        while (cv.size() >= 2 &&
               si * (m_points[cv[cv.size() - 1]] - m_points[cv[cv.size() - 2]])
                           .ccw(c - m_points[cv[cv.size() - 2]]) <
                   0) {
          cv.pop_back();
        }
        cv.push_back(k);
      }
      si *= -1;
    }

    copy(conv[0].begin(), conv[0].end(), back_inserter(m_hull));
    copy(next(conv[1].rbegin()), prev(conv[1].rend()), back_inserter(m_hull));
  }
  double diameter() const {
    double result = 0;
    const size_t n = m_hull.size();
    int j = 0;
    for (size_t i = 0; i < n; i++) {
      double d = ((*this)[i] - (*this)[j % n]).norm();
      double e = ((*this)[i] - (*this)[(j + 1) % n]).norm();
      while (d < e) {
        j++;
        d = e;
        e = ((*this)[i] - (*this)[(j + 1) % n]).norm();
      }
      result = max(result, d);
    }
    return result;
  }
  size_t size() const { return m_hull.size(); }
  const vector<int>& ids() const { return m_hull; }
  const Vec& operator[](size_t index) const {
    return m_points.at(m_hull.at(index));
  }
};

int main() {
  int n;
  cin >> n;

  vector<Vec> p;
  rep(i, n) {
    double x, y;
    cin >> x >> y;
    p.push_back(Vec({x, y}));
  }

  auto hull = Convex(p);
  cout << fixed << setprecision(7) << hull.diameter() << endl;
  return 0;
}