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 <iostream>
#include <complex>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;
typedef vector<Point> Polygon;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

namespace std{
    bool operator<(const Point &a, const Point &b){
        return !equals(a.X, b.X) ? a.X < b.X : a.Y < b.Y;
    }
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

double convexDiameter(Polygon pol){
    int n = pol.size();
    if(n <= 1) return 0;
    if(n == 2) return abs(pol[0] - pol[1]);

    int i = 0, j = 0;
    for(int k=0; k<n; k++){
        if(!(pol[i] < pol[k])) i = k;
        if(pol[j] < pol[k]) j = k;
    }

    double diameter = 0;
    int si = i, sj = j;
    while(i != sj || j != si){
        diameter = max(diameter, abs(pol[i] - pol[j]));
        if(cross(pol[(i+1)%n] - pol[i], pol[(j+1)%n] - pol[j]) < -EPS){
            i = (i + 1) % n;
        }
        else{
            j = (j + 1) % n;
        }
    }

    return diameter;
}

int main(){
    int n; cin>>n;
    Polygon pol;
    for(int i=0; i<n; i++){
        double x, y; cin>>x>>y;
        pol.emplace_back(x, y);
    }

    printf("%.10f\n", convexDiameter(pol));
}