Codeforces Vanya and Lanterns
/*
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
const int mod = 1000007;
const int high = 1003;
int ar[high];
int main()
{
fast;
int n , l , i , mxdist=0;
double ans;
while(~sf("%d %d", &n , &l))
{
for(i=0; i<n; i++)
{
sf("%d", &ar[i]);
}
sort(ar , ar+n);
mxdist = -1;
for(i=0; i<n-1; i++)
{
int def = ar[i+1] - ar[i];
mxdist = max(mxdist , def);
}
double tmp = (mxdist / 2.00) * 1.0;
double t = ((ar[0] - 0.0) * 1.0) > ((l - ar[n-1]) * 1.0) ? ((ar[0] - 0.0) * 1.0) : ((l*1.0 - ar[n-1]*1.0) * 1.0) ; // max(ar[0] - 0, l - ar[n-1])); for boundary detection
ans = tmp > t ? tmp : t;
pf("%.9f\n" , ans);
}
return 0;
}
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
const int mod = 1000007;
const int high = 1003;
int ar[high];
int main()
{
fast;
int n , l , i , mxdist=0;
double ans;
while(~sf("%d %d", &n , &l))
{
for(i=0; i<n; i++)
{
sf("%d", &ar[i]);
}
sort(ar , ar+n);
mxdist = -1;
for(i=0; i<n-1; i++)
{
int def = ar[i+1] - ar[i];
mxdist = max(mxdist , def);
}
double tmp = (mxdist / 2.00) * 1.0;
double t = ((ar[0] - 0.0) * 1.0) > ((l - ar[n-1]) * 1.0) ? ((ar[0] - 0.0) * 1.0) : ((l*1.0 - ar[n-1]*1.0) * 1.0) ; // max(ar[0] - 0, l - ar[n-1])); for boundary detection
ans = tmp > t ? tmp : t;
pf("%.9f\n" , ans);
}
return 0;
}
Comments
Post a Comment