#include <iostream>
#include <set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
set<pair<int,int>> s;
set<int> st;
int a[100010],b[100010],d[100010] = {};
vector<int> v;
int main(){
    int i,j,n,l; cin >> n >> l;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<=n;i++) cin >> b[i];
    for(i=1;i<=n;i++) d[i] = b[i] - a[i];
    a[0] = 0; a[i] = l + 1;
    for(i=0;i<=n + 1;i++){
        s.insert({a[i] - i,i}); st.insert(a[i] - i);
    }
    for(i=0;i<=n + 1;i++){
        if(d[i]==0) v.push_back(i);
    }
    ll ans = 0;
    for(i=1;i<v.size();i++){
        vector<pair<ll,ll>> v2,v3;
        for(j=v[i - 1] + 1;j<v[i];j++){
            if(!st.count(a[j] - j + d[j])){
                cout << -1 << endl;
                return 0;
            }
            if(d[j]<0) v2.push_back({(*(--s.upper_bound({a[j] - j + d[j],1000000000}))).second,j});
            else v3.push_back({(*s.lower_bound({a[j] - j + d[j],-1})).second,j}); 
        }
        for(j=0;j<(int)v2.size() - 1;j++){
            if(v2[j + 1].second - v2[j].second>1){
                cout << -1 << endl;
                return 0;
            }
        }
        for(j=0;j<(int)v3.size() - 1;j++){
            if(v3[j + 1].second - v3[j].second>1){
                cout << -1 << endl;
                return 0;
            }
        }
        if(v2.size()){
            ll cnt = 0,x = v2.back().first;
            for(j=v2.size() - 1;j>=0;j--){
                if(x!=v2[j].first){
                    ans += cnt; cnt = 0;
                }
                cnt = max(cnt,v2[j].second - v2[j].first);
                x = v2[j].first;
            }
            ans += cnt;
        }
        if(v3.size()){
            ll cnt = 0,x = v3[0].first;
            for(j=0;j<v3.size();j++){
                if(x!=v3[j].first){
                    ans += cnt; cnt = 0;
                }
                cnt = max(cnt,v3[j].first - v3[j].second);
                x = v3[j].first;
            }
            ans += cnt;
        }
    }
    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class T> int lwb(const V<T>& v, const T& a){return lower_bound(all(v),a) - v.begin();}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N;
	double D,H;
	cin >> N >> D >> H;
	double ans = 0;
	while(N--){
		double d,h; cin >> d >> h;
		chmax(ans,h-(H-h)/(D-d)*d);
	}
	cout << ans << endl;
}
