Advertisement
rengetsu

Codeforces_492B

Aug 2nd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. //Codeforces Round 492B
  2. #include <iomanip>
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7.     double l, n, k[1001], sub, max=0, top=-1, bot=-1;
  8.     cin >> l >> n;
  9.     for(int i=0;i<l;i++)
  10.     {
  11.         cin >> k[i];
  12.     }
  13.     for(int i=0;i<l;i++)
  14.     {
  15.         for(int y=0;y<l-1;y++)
  16.         {
  17.             if(k[y]>k[y+1])
  18.             {
  19.                 sub = k[y];
  20.                 k[y] = k[y+1];
  21.                 k[y+1] = sub;
  22.             }
  23.         }
  24.     }
  25.     for(int i=0;i<l;i++)
  26.     {
  27.         if(i!=0)
  28.         {
  29.             if((k[i]-k[i-1])>max)
  30.             {
  31.                 max = k[i]-k[i-1];
  32.             }
  33.         }
  34.         if(i==l-1)
  35.         {
  36.             top = n - k[i];
  37.             if((top*2)>max){max=top*2;}
  38.         }
  39.         if(i==0)
  40.         {
  41.             bot = k[i];
  42.             if((bot*2)>max){max=bot*2;}
  43.         }
  44.     }
  45.     cout << fixed << setprecision(10) << max/2;
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement