Advertisement
SergeyPGUTI

9.10(Ваня и фонари)

Mar 26th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <string.h>
  2. #include<cstdlib>
  3. #include<ctime>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <iomanip>
  7.  
  8. using namespace std;
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14.     int n,l;
  15.     double buff,Max=0,dist;
  16.     vector <double> v;
  17.     cin>>n>>l;
  18.     for (int i=0;i<n;i++)
  19.     {
  20.         cin>>buff;
  21.         v.push_back(buff);
  22.     }
  23.  
  24.     sort(v.begin(),v.end());
  25.  
  26.     for (int i=0;i<n-1;i++)
  27.     {
  28.         dist=v[i+1]-v[i];
  29.         if (dist>Max) Max=dist;
  30.     }
  31.     Max=Max/2;
  32.     if (v[0]>Max) {Max=v[0];}
  33.     if (l-v[n-1]>Max) {Max=l-v[n-1];}
  34.     cout<<fixed;
  35.         cout<<setprecision(9)<<Max;
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement