chillurbrain

10. Ваня и фонари.

May 21st, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner sc= new Scanner(System.in);
  8.         int n= sc.nextInt();
  9.         int l= sc.nextInt();
  10.         int[] num= new int[n];
  11.         for(int i = 0; i < n; i++){
  12.             num[i]= sc.nextInt();
  13.         }
  14.         Arrays.sort(num);
  15.         double maxreqrad= Math.max(num[0], l-num[n-1]);
  16.         for(int i = 1; i < n; i++) {
  17.             double RequiredRadius = (num[i]-num[i-1]) / 2.0;
  18.             if (RequiredRadius > maxreqrad) maxreqrad=RequiredRadius;
  19.         }
  20.         System.out.println(maxreqrad);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment