# Need help with codeforces "Vanya and lanterns"

So here’s the link to the question. Problem - B - Codeforces

Here is my solution: Submission #74751893 - Codeforces

``````#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define debug(var) cout << #var << ": " << var << "\n"
#define SORTV(vec) sort((vec).begin(), (vec).end())

void solve() {
int n, l; cin >> n >> l;  // number of lanterns and length of road
vector<int> lights(n);
for (int i = 0; i < n; ++i) {
cin >> lights[i];
}
SORTV(lights);
int maxDist = 2*max(lights[0], l-lights[n-1]);
for (int i = 0; i < n-1; ++i) {
maxDist = max(maxDist, lights[i+1]-lights[i]);
}
cout << maxDist/(double)2;
}

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
solve();
}
``````

Here’s the solution given in the editorial

``````#include <stdio.h>
#include <algorithm>
using namespace std;
int n,i,a[100500],rez,l;
int main()
{
scanf("%d%d",&n,&l);
for (i = 0; i < n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
rez = 2*max(a[0],l-a[n-1]);
for (i = 0; i < n-1; i++)
rez = max(rez, a[i+1]-a[i]);
printf("%.10f\n",rez/2.);
return 0;
}
``````

Although my solution follows the exact same logic it’s failing test case 3. (You can see the test case in the link to my submission after clicking "Click here to see test details at the bottom of the page)

Any idea what I’m doing wrong?

``cout<<fixed<<setprecision(10);``