Codeforces Round #280 (Div. 2) B

Source: Internet
Author: User

Topic:

B. Vanya and Lanternstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Vanya walks late at night along a straight street of lengthL, lit byNLanterns. Consider the coordinate system with the beginning of the street corresponding to the point0, and its end correspondingL. Then theI-th Lantern is at the point ai . The lantern lights all points of the the street is at the distance of theDFrom it, whereDis 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 Integers  n ,  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 be located on 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 Test (s) input
7 1515 5 3 7 9 14 0
Output
2.5000000000
Input
2 52 5
Output
2.0000000000
Note

Consider the second sample. At D=?2 the first lantern would light the segment [0,?4] of the the street, and the second lantern would light segment[3,?5]. Thus, the whole street would be lit.


Analysis: A long L Street, at some specified points will have some lanterns, ask the lantern minimum illumination radius of how much can illuminate the whole street.

Deal with the maximum number of adjacent elements, and note that there is no lantern at 0 or L.

#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <vector > #include <queue> #include <stack> #include <cassert> #include <algorithm> #include < cmath> #include <set> #include <limits> #include <map>using namespace std; #define MIN (A, B) ((a) < (b)? (a): (b) #define MAX (A, B) ((a) > (b)? (a): (b) #define F (i, n) for (int (i) =0; (i) < (n), + + (i)) #define REP (I, S, T) for (int (i) = (s);(i) <= (t), + + (i) #define UR EP (I, S, T) for (int (i) = (s);(i) >= (t);-(i)) #define REPOK (I, S, T, O) for (int (i) = (s);(i) <= (t) && (o); + + (i)) # Define MEM0 (Addr) memset ((addr), 0, sizeof ((addr))) #define PI 3.1415926535897932384626433832795#define Half_pi 1.5707963267948966192313216916398#define maxn 100000#define maxm 10000#define MOD 1000000007typedef Long Long ll;const  Double maxdouble = Numeric_limits<double>::max (); const double EPS = 1e-10;const int INF = 0x7fffffff;int A[1005];int Main () {    int n,l;        while (Cin>>n>>l) {for (int i=0;i<n;i++) {cin>>a[i];        } sort (a,a+n);        int ma =-1;            for (int i=1;i<n;i++) {int tmp = A[i]-a[i-1];        MA = max (TMP,MA);        } int x = (A[0]-0);        int y = (l-a[n-1]);        MA = max (ma,x);        MA = max (ma,y);        Double ans = (double) ma/2;    printf ("%.10lf\n", ans); }}




Codeforces Round #280 (Div. 2) B

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.