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 JAVA (judge verdict: Time Limit Exceeded)

public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    double[] x, y;
    int i, j;
    double s1x, s1y, s2x, s2y, sjx, sjy, max, l;

    n = sc.nextInt();
    x = new double[n];
    y = new double[n];

    for(i = 0;i < n;i++){
      x[i] = sc.nextDouble();
      y[i] = sc.nextDouble();
    }

    max = 0.0;
    for(i = 0;i < n;i++){
      s1x = y[(i - 1 + n) % n] - y[i];
      s1y =  - x[(i - 1 + n) % n] + x[i];
      s2x =  - y[(i + 1) % n] + y[i];
      s2y = x[(i + 1) % n] - x[i];
      for(j = 0;j < n;j++){
        sjx = x[j] - x[i];
        sjy = y[j] - y[i];
        if((s1x * sjy - sjx * s1y) * (s2x * sjy - s2y * sjy) <= 0){
          l = sjx * sjx + sjy * sjy;
          if(l > max)max = l;
        }
      }
    }

    System.out.println(Math.sqrt(max));

/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}