Hustlingbeast_Anish

Gajdendra_And_Scrolls_Anish

Jun 12th, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     ll n, x;
  9.     ld ans = (double)-1e18;
  10.     cin >> n >> x;
  11.     vector<ll> v(n);
  12.     for (ll i = 0; i < n; ++i)
  13.         cin >> v[i];
  14.     sort(v.begin(), v.end());
  15.     ld d = v[0];
  16.     if (v[n - 1] <= x)
  17.         if (x - v[n - 1] > d)
  18.             d = x - v[n - 1];
  19.     for (ll i = 1; i < n; ++i)
  20.     {
  21.         ld y = abs(v[i] - v[i - 1] + 0.0) / 2;
  22.         ans = max(ans, y);
  23.     }
  24.     ans = max(ans, d);
  25.     cout << fixed << setprecision(10) << ans << endl;
  26.     return 0;
  27. }
Tags: C++
Add Comment
Please, Sign In to add comment