#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 105;
int n;
pair<double,double> a[N];
pii dsu[N];
double dis[N][N];

int find(int x)
{
    if(dsu[x].F == x) return x;
    return dsu[x].F = find(dsu[x].F);
}

void merge(int x,int y)
{
    int p = find(x);
    int q = find(y);
    
    if(p == q) return;
    
    if(dsu[p].S > dsu[q].S) swap(p,q);
    
    dsu[q].S+=dsu[p].S;
    dsu[p].F = dsu[q].F;
}

//n is upper
//n+1 is lower

bool check(double r)
{
    f(i,n+2) dsu[i] = {i,1};
    
    f(i,n) f(j,n)
        if(dis[i][j] <= r ) merge(i,j);
    
    f(i,n) if(100 - a[i].S <= r) merge(i,n);
    f(i,n) if(a[i].S + 100 <= r) merge(i,n+1); 
        
    return find(n) != find(n+1);
}

signed main()
{
    fast;
    
   cin >> n;
    
   f(i,n) cin >> a[i].F >> a[i].S;
    
   vector<double> go;
    
   f(i,n) f(j,n) dis[i][j] = sqrt(
     (a[i].F - a[j].F)*(a[i].F - a[j].F ) + (a[i].S - a[j].S)*(a[i].S - a[j].S));
    
   f(i,n) f(j,n) go.pb(dis[i][j]);
   f(i,n) go.pb((100 - a[i].S));
   f(i,n) go.pb((a[i].S + 100));
    
   double res = 0; 
    
   for(auto x : go) 
       if(check(x - 1e-9)) res = max(res,x);
   
   cout << fixed << setprecision(4) << res/2;
}
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1e5+5;
int n,m,tp[N],a[N],b[N];
long long ans;

void GG(){
	write(-1);
	exit(0);
}

signed main(){
	read(n,m);
	for(int i=1;i<=n;i++) read(tp[i]),a[i]=tp[i]-tp[i-1]-1;a[n+1]=m-tp[n];
	for(int i=1;i<=n;i++) read(tp[i]),b[i]=tp[i]-tp[i-1]-1;b[n+1]=m-tp[n];n++;
	for(int i=1,j=1;i<=n;i++) if(b[i]){
		while(!a[j]) j++;
		int cur=0,l=j;
		while(j<=n&&cur<b[i]) cur+=a[j++];
		if(cur>b[i]) GG();
		ans+=max(i-l,0)+max(j-1-i,0);
	}
	write(ans);
}