B-bTime
limit:1000MS
Memory Limit:262144KB
64bit IO Format:%i64d &%i6 4u
Description
Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end Correspondin G to the point l. Then the i-th lantern are at the point aI. The lantern lights all points of the the street is at the distance of the very D from it, where d is some positive number, common for all lanterns.
Vanya Wonders:what is the minimum light radius D Should the lanterns has to light the whole street?
Input
The first line contains the integers n, l (1≤ n ≤1000, 1≤ l ≤10 9)-the number of lanterns and the length of the street respectively.
The next line contains n integers ai (0≤ ai ≤ l). Multiple lanterns can is located at the same point. The lanterns is located at the ends of the street.
Output
Print The minimum light radius D, needed to light the whole street. The answer would be a considered correct if its absolute or relative error doesn ' t exceed -9.
Sample Input
Input
7 15
15 5 3 7 9 14 0
Output
2.5000000000
Input
2 5
2 5
Output
2.0000000000
Hint
Consider the second sample. At d = 2 The first lantern would light the segment [0, 4] of the street, and the second lantern would light Segment [3, 5]. Thus, the whole street would be lit.
#include <iostream>#include<algorithm>#include<cstdio>#include<cmath>using namespacestd;intn,l;DoubleS,t,ans,r,u;inta[1005];intMain () {CIN>>n>>l; Doublef=0; for(intI=0; i<n; i++) Cin>>A[i]; Sort (A,a+N); for(intI=0; i<n-1; i++) {ans=a[i+1]-A[i]; if(f<ans) F=ans; } R=f/2; S=a[0]; T= (l-a[n-1]); Doubleu=Max (s,t); Doublev=Max (U,R); printf ("%.10lf\n", v);}
Question B (coverage problem)