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 <bits/stdc++.h>
using namespace std;

using db = double;
const db eps = 1e-9;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	bool operator <(poi p) const {
		return tie(x, y) < tie(p.x, p.y);
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
	db len() {
		return sqrt(x * x + y * y);
	}
};
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}

using vp = vector <poi>;
vp convex(vp v) {
	sort(v.begin(), v.end()); vp r;
	for(int i = 0; i < v.size(); i ++) {
		while(r.size() > 1 &&
			sgn(xmul(*++r.rbegin(), v[i], *r.rbegin())) >= 0)
			r.pop_back();
		r.push_back(v[i]);
	}
	int d = r.size();
	for(int i = (int)v.size() - 2; i >= 0; i --) {
		while(r.size() > d &&
			sgn(xmul(*++r.rbegin(), v[i], *r.rbegin())) >= 0)
			r.pop_back();
		if(i != 0) r.push_back(v[i]);
	}
	return r;
}

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(false);
	int n; cin >> n; vp v;
	for(int i = 0; i < n; i ++) {
		db x, y; cin >> x >> y;
		v.push_back({x, y});
	}
	v = convex(v);

	n = v.size();
	/*
	for(int i = 0; i < n; i ++)
		cout << v[i].x << ' ' << v[i].y << '\n';
		*/
	{
		db ans = 0;
		auto upd = [&](int i, int j) {
			db t = (v[i] - v[j]).len();
			if(t > ans) ans = t;
		};
		int j = 1 % n;
		for(int i = 0; i < n; i ++) {
			while(sgn(xmul(v[i], v[(i + 1) % n], v[j]),
				xmul(v[i], v[(i + 1) % n], v[(j + 1) % n])) < 0)
				j = (j + 1) % n;
			//cout << i << ' ' << j << '\n';
			upd(i, j); /*upd((i + 1) % n, j);*/
			/*upd(i, (j + 1) % n);*/ /*upd((i + 1) % n, (j + 1) % n);*/
		}
		cout << ans << '\n';
	}

	return 0;
}