➤ Problem Link : 492B. Vanya and Lanterns
✅ C++ Solution :
#include<bits/stdc++.h> using namespace std; #define ll long long int int main() { int n; int l; cin>>n>>l; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; sort(arr,arr+n); int maxi=max(arr[0]-0,l-arr[n-1])*2; for(int i=0;i<n-1;i++) { if((arr[i+1]-arr[i])>maxi) maxi=(arr[i+1]-arr[i]); // cout<<maxi<<endl; } double f=(double)maxi/2.000; cout<<fixed<<f<<endl; return 0; }
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!