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++11 (judge verdict: Accepted)

#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    } else {
        return d < 0 ? -1 : 1;
    }
}

struct Vector {
    double x, y;

    Vector(double x = 0, double y = 0) : x(x), y(y) {
    }
    
    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double length(const Vector& a) {
    return sqrt(dot(a, a));
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

double ccw(const Point& a, const Point& b, const Point& c) {
    return cross(b - a, c - a);
}

double diameter(vector<Point> s) {
    vector<Point> p = s;
    int n = p.size();
    if (n == 2) {
        return length(p[0] - p[1]);
    }
    int i = 0, j = 0;
    
    for (int k = 0; k < n; k++) {
        if (p[i] < p[k]) {
            i = k;
        }
        if (!(p[j] < p[k])) {
            j = k;
        }
    }
    //cout<<i<<" "<<j<<endl;
    double res = 0;
    
    int si = i, sj = j;
    
    while (i != sj || j != si) {
        //cout<<i<<" "<<j<<endl;
        res = max(res, length(p[i] - p[j]));
        if (dcmp(cross(p[(i + 1) % n] - p[i], p[(j + 1) % n] - p[j])) < 0) {
            i = (i + 1) % n;
        } else {
            j = (j + 1) % n;
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
 
    cout << fixed << setprecision(8) << diameter(p) << endl;

    return 0;
}