fork download
  1. # include <iostream>
  2. # include <stdio.h>
  3. # include <math.h>
  4. # include <list>
  5. # include <algorithm>
  6. # include <limits>
  7. #include <vector>
  8. #include <ctype.h> // for isupper function
  9. #include <string>
  10. #include <sstream>
  11. // #include <bits/stdc++.h>
  12. using namespace std;
  13.  
  14. #define sz(v) int((v).size())
  15. #define all(v) (v).begin(), (v).end()
  16.  
  17. typedef long long LL;
  18.  
  19. typedef long double LD;
  20. string NumberToString ( LL Number )
  21. {
  22. stringstream ss;
  23. ss << Number;
  24. return ss.str();
  25. }
  26.  
  27.  
  28. LL StringToNumber ( const string &Text )//Text not by const reference so that the function can be used with a
  29. { //character array as argument
  30. stringstream ss(Text);
  31. LL result;
  32. return ss >> result ? result : 0;
  33. }
  34.  
  35. int main(){
  36. //std::ios::sync_with_stdio(false);
  37. // uncomment it or use scanf and printf
  38. //cout << "Minimum value for long long int(or other datatype): " << std::numeric_limits<long long int>::min() << '\n';
  39. // instead of min() use max() to get the maximum value in the previous case
  40. //scanf returns the number of items succesfully converted or EOF on error
  41. LL n, l;
  42. cin>>n>>l;
  43. LD arr[n];
  44. for(LL i=0; i<n; i++){
  45. cin>>arr[i];
  46. }
  47. sort(arr, arr+n);
  48.  
  49. LD diff = arr[1]-arr[0];
  50. if(n==1){
  51. diff=arr[0];
  52. }
  53. for(LL i=1; i<=n-2; i++){
  54. if((arr[i+1]-arr[i])>diff){
  55. diff=arr[i+1]-arr[i];
  56. }
  57. }
  58. LD a = ((LD)diff)/2;
  59. LD b = arr[0]>(l- arr[n-1])?arr[0]:(l- arr[n-1]);
  60.  
  61. LD ans = b>a?b:a;
  62. printf("%.10Lf \n", ans);
  63.  
  64. }
Runtime error #stdin #stdout 0s 3348KB
stdin
Standard input is empty
stdout
Standard output is empty