fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class A406 {
  6. public static void main(String[] args) {
  7. int[][] matrix;
  8. double maxDistance = 0;
  9. double distance;
  10. Scanner scanner = new Scanner(System.in);
  11. int m = scanner.nextInt();
  12. matrix = new int[2][m];
  13.  
  14. for (int i = 0; i < 2; i++)
  15. for (int j = 0; j < m; j++)
  16. matrix[i][j] = scanner.nextInt();
  17.  
  18. for (int i = 0; i < m; i++) {
  19. for (int j = i + 1; j < m; j++) {
  20. distance = Math.sqrt((matrix[0][j] - matrix[0][i]) * (matrix[0][j] - matrix[0][i]) + (matrix[1][j] - matrix[1][i]) * (matrix[1][j] - matrix[1][i]));
  21. if (distance > maxDistance) {
  22. maxDistance = distance;
  23. }
  24. }
  25. }
  26.  
  27. System.out.println(maxDistance);
  28. }
  29. }
Success #stdin #stdout 0.16s 321344KB
stdin
3
2 8 4
9 1 5
stdout
10.0