#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <cstring>
#define LL long long
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;

const int maxn = 2e3+10;

int sgn(int x) {
	if (x)
		return x > 0 ? 1 : -1;
	return 0;
}

int n, l[maxn], r[maxn], a[maxn];
LL dp[maxn], ans = INF, k;

int main() {
	scanf("%d%lld", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%d", l + i, r + i, a + i);
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int remain = k;
		LL bullet = 0;
		for (int j = i + 1; j <= n; j++) {
			// can't clear this wave
			if (remain + k * (r[j] - l[j]) < a[j])
				break;
			else {
				int now_remain;
				if (remain >= a[j])
					now_remain = remain - a[j];
				else if ((a[j] - remain) % k)
					now_remain = k - (a[j] - remain) % k;
				else
					now_remain = 0;
				bullet += a[j];
				if (j < n)
					if (r[j] < l[j+1] || remain + k * (r[j] - l[j] - 1) >= a[j])
						dp[j] = min(dp[j], dp[i] + bullet + now_remain);
				if (j == n) {
					ans = min(ans, dp[i] + bullet);
				}
				remain = now_remain;
			}
		}
	}
	printf("%lld\n", ans < INF ? ans : -1);
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <cstring>
#define LL long long
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;

const int maxn = 2e3+10;

int n, l[maxn], r[maxn], a[maxn];
LL dp[maxn], ans = INF, k;

int main() {
	scanf("%d%lld", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%d", l + i, r + i, a + i);
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int remain = k;
		LL bullet = 0;
		for (int j = i + 1; j <= n; j++) {
			// can't clear this wave
			if (remain + k * (r[j] - l[j]) < a[j])
				break;
			else {
				if (remain >= a[j])
					remain -= a[j];
				else if ((a[j] - remain) % k)
					remain = k - (a[j] - remain) % k;
				else
					remain = 0;
				bullet += a[j];
				//there's time between this wave and next wave
				//or there's time in this wave
				if ((j < n && r[j] < l[j+1]) || (remain + k * (r[j] - l[j]) > a[j]))
					dp[j] = min(dp[j], dp[i] + bullet + remain);
				if (j == n) {
					ans = min(ans, dp[i] + bullet);
				}
			}
		}
	}
	printf("%lld\n", ans < INF ? ans : -1);
	return 0;
}


#include<bits/stdc++.h>

#define rd(x) x=read()

#define int long long

#define N 2005

using namespace std;

int n,k;
int l[N],r[N],a[N],f[N];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();if(ch==-1)return 0;}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

inline void write(int x)
{
    if(x<0){putchar('-');x=-x;}
    if(x>=10)write(x/10);
    putchar(x%10+'0');
}

int ans;

signed main()
{
	rd(n),rd(k);
	for(int i=1;i<=n;i++)rd(l[i]),rd(r[i]),rd(a[i]);
	for(int i=n;i>=1;i--)
	{
		int cur=a[i];if(r[i]==l[i+1])cur+=f[i+1];
		if(cur>(r[i]-l[i]+1)*k){puts("-1");return 0;}
		f[i]=max(0ll,cur-(r[i]-l[i])*k);
	}
	for(int i=1,j=k;i<=n;i++){if(j<f[i])ans+=j,j=k;ans+=a[i],j=(j-a[i]%k+k)%k;}
	cout<<ans<<endl;

    return 0;
}


#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <math.h>
#include <cstring>
#include <time.h>
#include <complex>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <set>

#pragma warning(disable:4996)

template<typename T> T min(T x, T y)
{
	return x < y ? x : y;
}
template<typename T> T max(T x, T y)
{
	return x > y ? x : y;
};

const long long INF = 20000000050000;
const long long mod = 998244353;
const long long MAXN = 2005;

int N, K;
int L[MAXN], R[MAXN], a[MAXN];
long long suma[MAXN], c[MAXN][MAXN];//第i波之前装弹，不浪费地打完第k波,在下一波之前装满
long long f[MAXN];//消灭前k波并装满

void init()
{
	scanf("%d %d", &N, &K);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d %d %d", L + i, R + i, a + i);
		suma[i] = suma[i - 1] + a[i];
	}
	L[N + 1] = R[N] + 100;

	for (int i = 1; i <= N; i++)
	{
		c[i][i - 1] = 0;
		int t = K;
		for (int j = i; j <= N; j++)
		{
			if (t < 0)
			{
				c[i][j] = INF;
				continue;
			}
			int time = R[j] - L[j] + 1;
			if (a[j] < t)
			{
				t -= a[j];
				c[i][j] = (L[j + 1] == L[j] ? INF : suma[j] - suma[i - 1] + t);
				continue;
			}
			int tot = a[j] - t; time--;
			int tmp = (tot + K - 1) / K;
			if (tmp > time)
				c[i][j] = INF, t = -1;
			else if (tmp == time)
				t = tmp * K - tot,
				c[i][j] = (L[j + 1] == R[j] ? INF : suma[j] - suma[i - 1] + t);
			else
			{
				t = tmp * K - tot;
				c[i][j] = suma[j] - suma[i - 1] + t;
				t += (!t) * K;
			}
		}
	}
}

void solve()
{
	for (int i = 1; i <= N; i++)
	{
		f[i] = INF;
		for (int j = 1; j <= i; j++)
			f[i] = min(f[i], f[j - 1] + c[j][i]);
	}
	if (f[N] >= INF)
	{
		printf("-1\n");
		return;
	}
	long long ans = INF;
	for (int i = 1; i <= N; i++)
		if (c[i][N] < INF)
			ans = min(ans, f[i - 1] + suma[N] - suma[i - 1]);
	printf("%lld\n", ans);
}

int main()
{
	init();
	solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 2000 + 5;
const int inf = 2e14;
int n, k, ans = inf, a[N], l[N], r[N], dp[N][2], w[N][N][2], sta[N][N][2];
int read() {
    char c; int x = 0, f = 1;
    c = getchar();
    while (c > '9' || c < '0') { if(c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
signed main() {
    n = read(), k = read();
    rep(i, 1, n) l[i] = read(), r[i] = read(), a[i] = read();
    rep(i, 0, n) rep(j, 0, n) w[i][j][0] = w[i][j][1] = inf, sta[i][j][0] = sta[i][j][1] = -1;
    rep(i, 0, n) {
        int tmp = k, last = r[i] - 1;
        w[i][i][0] = w[i][i][1] = k, sta[i][i][0] = 0, sta[i][i][1] = 1;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][0] = w[i][j - 1][0] + a[j] - tmp, tmp -= a[j];
                w[i][j][0] += tmp;
                sta[i][j][0] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][0] = w[i][j - 1][0] + a[j] - tmp, tmp = need * k - (a[j] - tmp);
                w[i][j][0] += tmp;
                last = fir + need - 1, sta[i][j][0] = (need == r[j] - fir);
            }
        }
        last = r[i], tmp = k;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][1] = w[i][j - 1][1] + a[j] - tmp, tmp -= a[j];
                w[i][j][1] += tmp;
                sta[i][j][1] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][1] = w[i][j - 1][1] + a[j] - tmp, tmp = need * k - (a[j] - tmp);
                w[i][j][1] += tmp;
                last = fir + need - 1, sta[i][j][1] = (need == r[j] - fir);
            }
        }
    }
    rep(i, 1, n) dp[i][0] = dp[i][1] = inf;
    rep(i, 1, n) {
        rep(j, 0, i - 1) {
            if(sta[j][i][0] != -1) dp[i][sta[j][i][0]] = min(dp[i][sta[j][i][0]], dp[j][0] + w[j][i][0]);
            if(sta[j][i][1] != -1) dp[i][sta[j][i][1]] = min(dp[i][sta[j][i][1]], dp[j][1] + w[j][i][1]);
        }
    }
    rep(i, 0, n) rep(j, 0, n) w[i][j][0] = w[i][j][1] = inf, sta[i][j][0] = sta[i][j][1] = -1;
    rep(i, 0, n) {
        int tmp = k, last = r[i] - 1;
        w[i][i][0] = w[i][i][1] = 0, sta[i][i][0] = 0, sta[i][i][1] = 1;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][0] = w[i][j - 1][0] + a[j], tmp -= a[j];
                sta[i][j][0] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][0] = w[i][j - 1][0] + a[j], tmp = need * k - (a[j] - tmp);
                last = fir + need - 1, sta[i][j][0] = (need == r[j] - fir);
            }
        }
        last = r[i], tmp = k;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][1] = w[i][j - 1][1] + a[j], tmp -= a[j];
                sta[i][j][1] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][1] = w[i][j - 1][1] + a[j], tmp = need * k - (a[j] - tmp);
                last = fir + need - 1, sta[i][j][1] = (need == r[j] - fir);
            }
        }
    }
    rep(i, 0, n - 1) {
        if(sta[i][n][0] != -1) ans = min(ans, dp[i][0] + w[i][n][0]);
        if(sta[i][n][1] != -1) ans = min(ans, dp[i][1] + w[i][n][1]);
    }
    printf("%lld", ans == inf ? -1 : ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 2000 + 5;
const int inf = 2e12;
int n, k, ans = inf, a[N], l[N], r[N], dp[N][2], w[N][N][2], sta[N][N][2];
int read() {
    char c; int x = 0, f = 1;
    c = getchar();
    while (c > '9' || c < '0') { if(c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
signed main() {
    n = read(), k = read();
    rep(i, 1, n) l[i] = read(), r[i] = read(), a[i] = read();
    rep(i, 0, n) rep(j, 0, n) w[i][j][0] = w[i][j][1] = inf, sta[i][j][0] = sta[i][j][1] = -1;
    rep(i, 0, n) {
        int tmp = k, last = r[i] - 1;
        w[i][i][0] = w[i][i][1] = k, sta[i][i][0] = 0, sta[i][i][1] = 1;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][0] = w[i][j - 1][0] + a[j] - tmp, tmp -= a[j];
                w[i][j][0] += tmp;
                sta[i][j][0] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][0] = w[i][j - 1][0] + a[j] - tmp, tmp = need * k - (a[j] - tmp);
                w[i][j][0] += tmp;
                last = fir + need - 1, sta[i][j][0] = (need == r[j] - fir);
            }
        }
        last = r[i], tmp = k;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][1] = w[i][j - 1][1] + a[j] - tmp, tmp -= a[j];
                w[i][j][1] += tmp;
                sta[i][j][1] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][1] = w[i][j - 1][1] + a[j] - tmp, tmp = need * k - (a[j] - tmp);
                w[i][j][1] += tmp;
                last = fir + need - 1, sta[i][j][1] = (need == r[j] - fir);
            }
        }
    }
    rep(i, 1, n) dp[i][0] = dp[i][1] = inf;
    rep(i, 1, n) {
        rep(j, 0, i - 1) {
            if(sta[j][i][0] != -1) dp[i][sta[j][i][0]] = min(dp[i][sta[j][i][0]], dp[j][0] + w[j][i][0]);
            if(sta[j][i][1] != -1) dp[i][sta[j][i][1]] = min(dp[i][sta[j][i][1]], dp[j][1] + w[j][i][1]);
        }
    }
    rep(i, 0, n) rep(j, 0, n) w[i][j][0] = w[i][j][1] = inf, sta[i][j][0] = sta[i][j][1] = -1;
    rep(i, 0, n) {
        int tmp = k, last = r[i] - 1;
        w[i][i][0] = w[i][i][1] = 0, sta[i][i][0] = 0, sta[i][i][1] = 1;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][0] = w[i][j - 1][0] + a[j], tmp -= a[j];
                sta[i][j][0] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][0] = w[i][j - 1][0] + a[j], tmp = need * k - (a[j] - tmp);
                last = fir + need - 1, sta[i][j][0] = (need == r[j] - fir);
            }
        }
        last = r[i], tmp = k;
        rep(j, i + 1, n) {
            int fir = max(last + 1, l[j]);
            if(tmp >= a[j]) {
                if(fir > r[j]) break;
                w[i][j][1] = w[i][j - 1][1] + a[j], tmp -= a[j];
                sta[i][j][1] = (fir == r[j]);
            }
            else {
                int need = ceil(1.0 * (a[j] - tmp) / k);
                if(need > r[j] - fir) break;
                w[i][j][1] = w[i][j - 1][1] + a[j], tmp = need * k - (a[j] - tmp);
                last = fir + need - 1, sta[i][j][1] = (need == r[j] - fir);
            }
        }
    }
    rep(i, 0, n - 1) {
        if(sta[i][n][0] != -1) ans = min(ans, dp[i][0] + w[i][n][0]);
        if(sta[i][n][1] != -1) ans = min(ans, dp[i][1] + w[i][n][1]);
    }
    printf("%lld", ans == inf ? -1 : ans);
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;long long l[2005],r[2005],a[2005],f[2005];
int main() {int n;long long k,ans=0,_;scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;++i) scanf("%lld%lld%lld",l+i,r+i,a+i);
	for (int i=n;i;--i) {
		*a=a[i]+(r[i]==l[i+1]?f[i+1]:0);
		if (*a>(r[i]-l[i]+1)*k) return 0*puts("-1");
		f[i]=max(*a-(r[i]-l[i])*k,0LL);
	}_=k;for (int i=1;i<=n;++i) {
		if (_<f[i]) ans+=_,_=k;
		ans+=a[i],_=((_-a[i])%k+k)%k;
	}printf("%lld",ans);return 0;
}


/*
after dusk passed,
there is a starry sky.
*/
#include <bits/stdc++.h>
#define int long long
#define inf 1e18
#define m_k make_pair
using namespace std;
const int N=2100;
int n,k,l[N],r[N],a[N],dp[N];
inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	return x*f;
}
signed main()
{
	n=read();k=read();
	for (int i=1;i<=n;i++) l[i]=read(),r[i]=read(),a[i]=read();
	bool bl=1;
	int now=k;
	for (int i=1;i<=n;i++)
	{
		if (l[i]>r[i-1]) now=k;
		now=min(k,now+(r[i]-l[i])*k-a[i]);
		if (now<0) bl=0;
	}
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++) dp[i]=inf;
	dp[0]=0;
	for (int i=0;i<n;i++)
	{
		int now=k,cnt=k;
		for (int j=i+1;j<=n;j++)
		{
			if (now+(r[j]-l[j])*k<a[j]) break;
			int all=max(0ll,a[j]-now);
			cnt+=((all+k-1)/k)*k;
			now=((all+k-1)/k)*k+now-a[j];
			if (j==n)
			{
				dp[j]=min(dp[j],dp[i]+cnt-now);
				continue;
			}
			if ((all+k-1)/k<r[j]-l[j]||l[j+1]>r[j]) dp[j]=min(dp[j],dp[i]+cnt);
		}
	}
	printf("%lld\n",dp[n]);
}


/*
after dusk passed,
there is a starry sky.
*/
#include <bits/stdc++.h>
#define int long long
#define inf 1e18
#define m_k make_pair
using namespace std;
const int N=2100;
int n,k,l[N],r[N],a[N],dp[N];
inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	return x*f;
}
signed main()
{
	n=read();k=read();
	for (int i=1;i<=n;i++) l[i]=read(),r[i]=read(),a[i]=read();
	bool bl=1;
	int now=k;
	for (int i=1;i<=n;i++)
	{
		if (l[i]>r[i-1]) now=k;
		now=min(k,now+(r[i]-l[i])*k-a[i]);
		if (now<0) bl=0;
	}
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++) dp[i]=inf;
	dp[0]=0;
	for (int i=0;i<n;i++)
	{
		int now=k,cnt=0;
		for (int j=i+1;j<=n;j++)
		{
			if (j==n)
			{
				if (now+(r[i]-l[i])*k>=a[i]) dp[j]=min(dp[j],dp[i]+cnt+a[j]);
				continue;
			}
			if ((a[j]-now+k-1)/k<r[j]-l[j]) dp[j]=min(dp[j],dp[i]+cnt+((a[j]-now+k-1)/k)*k+now);
			cnt+=((a[j]-now+k-1)/k)*k+now;
			now=((a[j]-now+k-1)/k)*k+now-a[j];
		}
	}
	printf("%lld\n",dp[n]);
}


#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=2009;
	int n,K,L[N],R[N],a[N],g[N][N],h[N][N],f[N],p[N][N];
	int main(){
		n=read<int>(),K=read<int>();
		for(int i=1;i<=n;i++)
			L[i]=read<int>(),R[i]=read<int>(),a[i]=read<int>();

		memset(g,-1,sizeof g),memset(h,-1,sizeof h),memset(p,-1,sizeof p);
		for(int i=1;i<=n;i++){
			int tmp=K,sum=0;
			for(int j=i;j<=n;j++){
				int peg=0;
				if((R[j]-L[j]-1)*K+tmp>=a[j]) peg=1;

				if((R[j]-L[j])*K+tmp>=a[j]){
					if(tmp<=a[j]){
						sum+=(a[j]-tmp)/K*K+tmp,tmp=K-(a[j]-tmp)%K,sum+=K-tmp;
						if(tmp==K) tmp=0;
					}else sum+=a[j],tmp-=a[j];
					g[i][j]=((sum-1)/K+1)*K,h[i][j]=sum;
				}else break;
				if(peg) p[i][j]=g[i][j];
				//	cout<<sum<<" "<<tmp<<endl;
			}
		}
	//	return 0;

	//	for(int i=1;i<=n;i++){
	//		for(int j=i;j<=n;j++) cout<<h[i][j]<<" ";
	//		cout<<endl;
	//	}for(int i=1;i<=n;i++){
	//		for(int j=i;j<=n;j++) cout<<g[i][j]<<" ";
	//		cout<<endl;
	//	}for(int i=1;i<=n;i++){
	//		for(int j=i;j<=n;j++) cout<<p[i][j]<<" ";
	//		cout<<endl;
	//	}

		memset(f,0x3f,sizeof f);
		L[n+1]=f[0],f[0]=0;
		for(int i=1;i<=n;i++)
			if(L[i+1]!=R[i]){
				if(i!=n){
					for(int j=0;j<i;j++)
						if(~g[j+1][i]) f[i]=min(f[i],f[j]+g[j+1][i]);
				}else{
					for(int j=0;j<i;j++)
						if(~h[j+1][i]) f[n]=min(f[n],f[j]+h[j+1][i]);
				}
			}else{
				if(i!=n){
					for(int j=0;j<i;j++)
						if(~p[j+1][i]) f[i]=min(f[i],f[j]+p[j+1][i]);
				}else{
					for(int j=0;j<i;j++)
						if(~h[j+1][i]) f[n]=min(f[n],f[j]+h[j+1][i]);
				}
			}

		for(int i=1;i<=n;i++) cout<<f[i]<<" ";cout<<endl;
		if(f[n]==f[n+1]) puts("-1");
		else printf("%lld",f[n]);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}


#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=2009;
	int n,K,L[N],R[N],a[N],g[N][N],h[N][N],f[N],p[N][N];
	int main(){
		n=read<int>(),K=read<int>();
		for(int i=1;i<=n;i++)
			L[i]=read<int>(),R[i]=read<int>(),a[i]=read<int>();

		memset(g,-1,sizeof g),memset(h,-1,sizeof h),memset(p,-1,sizeof p);
		for(int i=1;i<=n;i++){
			int tmp=K,sum=0;
			for(int j=i;j<=n;j++){
				if((R[j]-L[j])*K+tmp>=a[j]){
					if(tmp<=a[j]){
						sum+=(a[j]-tmp)/K*K+tmp,tmp=K-(a[j]-tmp)%K,sum+=K-tmp;
						if(tmp==K) tmp=0;
					}else sum+=a[j],tmp-=a[j];
					g[i][j]=((sum-1)/K+1)*K,h[i][j]=sum;
				}else break;
				if((R[j]-L[j]-1)*K+tmp>=a[j]) p[i][j]=g[i][j];
				else p[i][j]=-1;
			//	cout<<sum<<" "<<tmp<<endl;
			}
		}
	//	return 0;

	//	for(int i=1;i<=n;i++){
	//		for(int j=i;j<=n;j++) cout<<h[i][j]<<" ";
	//		cout<<endl;
	//	}for(int i=1;i<=n;i++){
	//		for(int j=i;j<=n;j++) cout<<g[i][j]<<" ";
	//		cout<<endl;
	//	}

		memset(f,0x3f,sizeof f);
		L[n+1]=f[0],f[0]=0;
		for(int i=1;i<=n;i++)
			if(L[i+1]!=R[i]){
				if(i!=n){
					for(int j=0;j<i;j++)
						if(~g[j+1][i]) f[i]=min(f[i],f[j]+g[j+1][i]);
				}else{
					for(int j=0;j<i;j++)
						if(~h[j+1][i]) f[n]=min(f[n],f[j]+h[j+1][i]);
				}
			}else{
				if(i!=n){
					for(int j=0;j<i;j++)
						if(~p[j+1][i]) f[i]=min(f[i],f[j]+p[j+1][i]);
				}else{
					for(int j=0;j<i;j++)
						if(~h[j+1][i]) f[n]=min(f[n],f[j]+h[j+1][i]);
				}
			}

	//	for(int i=1;i<=n;i++) cout<<f[i]<<" ";cout<<endl;
		if(f[n]==f[n+1]) puts("-1");
		else printf("%lld",f[n]);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e13;
    while (true) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
        if (IsEqual(l, r)) break;
    }
    if (IsEqual(r,1e9)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-4) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e10;
    while (true) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
        if (IsEqual(l, r)) break;
    }
    if (IsEqual(r,1e10)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
ii a[maxn];
db beta[maxn], alpha[maxn], t;

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(ii a, ii b) {
    return db(a.fi)*t-db(a.se)>db(b.fi)*t-db(b.se);
}

bool check(db val) {
    t = val;
    sort(a+1, a+n+1, cmp);
    FOR(i, 1, n) beta[i] = db(a[i].fi)*t-db(a[i].se);
    FOR(i, 1, n) alpha[i] = t*db(p) - beta[i];
    db s=0;
    FOR(i, 1, n) {
        if (alpha[i]<s) return false;
        s += beta[i];
    }
    return true;
}

void bisect() {
    db l=0, r=1e13;
    int cnt = 0;
    while (cnt++<=100) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    if (IsEqual(r,1e13)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    //ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-5) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e11;
    while (true) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
        if (IsEqual(l, r)) break;
    }
    if (IsEqual(r,1e11)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
db p;
struct iii {
    db fi, se, c;
    iii() {}
    iii(db x, db y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-5) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = a[i].fi*t-a[i].se;
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*p;
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e11;
    while (true) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
        if (IsEqual(l, r)) break;
    }
    if (IsEqual(r,1e11)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
ii a[maxn];
db beta[maxn], alpha[maxn], t;

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(ii a, ii b) {
    return db(a.fi)*t-db(a.se)>db(b.fi)*t-db(b.se);
}

bool check(db val) {
    t = val;
    sort(a+1, a+n+1, cmp);
    FOR(i, 1, n) beta[i] = db(a[i].fi)*t-db(a[i].se);
    FOR(i, 1, n) alpha[i] = t*db(p) - beta[i];
    db s=0;
    FOR(i, 1, n) {
        if (alpha[i]<s) return false;
        s += beta[i];
    }
    return true;
}

void bisect() {
    db l=0, r=1e11;
    int cnt = 0;
    while (cnt++<=60) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    if (IsEqual(r,1e13)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    //ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e9;
    int cnt = 0;
    while (cnt++<=45) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    if (IsEqual(r,1e9)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
ii a[maxn];
db beta[maxn], alpha[maxn], t;

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(ii a, ii b) {
    return db(a.fi)*t-db(a.se)>db(b.fi)*t-db(b.se);
}

bool check(db val) {
    t = val;
    sort(a+1, a+n+1, cmp);
    FOR(i, 1, n) beta[i] = db(a[i].fi)*t-db(a[i].se);
    FOR(i, 1, n) alpha[i] = t*db(p) - beta[i];
    db s=0;
    FOR(i, 1, n) {
        if (alpha[i]<s) return false;
        s += beta[i];
    }
    return true;
}

void bisect() {
    db l=0, r=1e9;
    int cnt = 0;
    while (cnt++<=36) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    if (IsEqual(r,1e9)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    //ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
ii a[maxn];
db beta[maxn], alpha[maxn], t;

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(ii a, ii b) {
    return db(a.fi)*t-db(a.se)>db(b.fi)*t-db(b.se);
}

bool check(db val) {
    t = val;
    sort(a+1, a+n+1, cmp);
    FOR(i, 1, n) beta[i] = db(a[i].fi)*t-db(a[i].se);
    FOR(i, 1, n) alpha[i] = t*db(p) - beta[i];
    db s=0;
    FOR(i, 1, n) {
        if (alpha[i]<s) return false;
        s += beta[i];
    }
    return true;
}

void bisect() {
    db l=0, r=1e7;
    int cnt = 0;
    while (cnt++<=36) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    if (IsEqual(r,1e7)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e13;
    while (true) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
        if (IsEqual(l, r)) break;
    }
    if (IsEqual(r,1e13)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e6;
    int cnt = 0;
    while (cnt++<=35) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    if (IsEqual(r,1e6)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
ii a[maxn];
db beta[maxn], alpha[maxn], t;

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(ii a, ii b) {
    return db(a.fi)*t-db(a.se)>db(b.fi)*t-db(b.se);
}

bool check(db val) {
    t = val;
    sort(a+1, a+n+1, cmp);
    FOR(i, 1, n) beta[i] = db(a[i].fi)*t-db(a[i].se);
    FOR(i, 1, n) alpha[i] = t*db(p) - beta[i];
    db s=0;
    FOR(i, 1, n) {
        if (alpha[i]<s) return false;
        s += beta[i];
    }
    return true;
}

void bisect() {
    db l=0, r=1e11;
    int cnt = 0;
    while (cnt++<=60) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    if (IsEqual(r,1e11)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    //ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-6) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e13;
    int cnt = 0;
    while (cnt++<=45) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
        if (IsEqual(l, r)) break;
    }
    if (IsEqual(r,1e9)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n;
ll p;
struct iii {
    ll fi, se;
    db c;
    iii() {}
    iii(ll x, ll y) {fi = x; se = y;}
} a[maxn];

bool IsEqual(db a, db b, db _eps=1e-4) {
    return abs(a-b)<=_eps;
}

bool cmp(iii a, iii b) {
    return a.c>b.c;
}

bool check(db t) {
    FOR(i, 1, n) a[i].c = db(a[i].fi)*t-db(a[i].se);
    sort(a+1, a+n+1, cmp);
    db s=0, tmp = t*db(p);
    FOR(i, 1, n) {
        if (tmp-a[i].c<s) return false;
        s += a[i].c;
    }
    return true;
}

void bisect() {
    db l=0, r=1e18;
    while (true) {
        db mid = (l+r)/2;
        if (check(mid)) l = mid;
        else r = mid;
        if (IsEqual(l, r)) break;
    }
    if (IsEqual(r,1e18)) cout << -1;
    else cout << setiosflags(ios::fixed) << setprecision(10) << r;
}

int main() {
    //freopen("input.in", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> p;
    FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
    bisect();
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=1000000000000000000.0;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0001;
    ll cnt=200;
    while(cnt--){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    if(l>100000000000000000.0) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=1000000000000000.000000;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0000001;
    while((h-l)>eps){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    if(l>100000000000000.000) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=1000000000000000000.0;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0001;
    ll cnt=1000;
    while(cnt--){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    if(l>100000000000000000.0) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=1000000000000000000.000000;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0000001;
    while((h-l)>eps){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    if(fabs(l-inf2)<eps) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=1000000000000000000.000000;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0001;
    while((h-l)>eps){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    if(l>100000000000000000.000) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p,ck;
ld inf2=10000000000000000.000000;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) {
        cin>>a[i]>>b[i];
        ck+=a[i];
    }
    if(ck<=p){
        cout<<"-1\n";
        return 0;
    }
    ld l=0.000,h=inf2,eps=0.0000001;
    while((h-l)>eps){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=1000000000000000000.000000;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0000001;
    while((h-l)>eps){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    if(l>100000000000000000.000) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p,ck;
ld inf2=10000000000000000.0;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) {
        cin>>a[i]>>b[i];
        ck+=a[i];
    }
    if(p>=ck){
        cout<<"-1\n";
        return 0;
    }
    ld l=0.000,h=inf2,eps=0.0001;
    ll cnt=1000;
    while(cnt--){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=100000000000001.0;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0001;
    while((h-l)>eps){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x+0.00001;
        else h=x;
    }
    precision(4);
    if(l>100000000000000.0) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


//AGHORii
//Deshwal bhosdike stalking band krde
#include<bits/stdc++.h>
#define rep(a,b,c) for((a)=(int)(b);(a)<=(int)(c);(a)++)
#define per(a,b,c) for((a)=(int)(c);(a)>=(int)(b);(a)--)
#define mem(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,(-1),sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define MP make_pair
#define fi first
#define se second
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(x) ((int)((x).size()))
#define all(x) ((x).begin()), ((x).end())
#define rall(x) ((x).rbegin()), ((x).rend())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll,ll > pi;
typedef pair< ll,pi > pii;
typedef vector< ll > vi;
typedef vector< pi > vii;
const ll mod=1000000007;
const ll inf=1e15+21;
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
void precision(ll pr){ cout.precision(pr); cout<<fixed; }

const int N=1e6+21;
ld a[N],b[N],p;
ld inf2=1000000000000000.000000;
int main()
{
    ll i,j,k,n;
    cin>>n;
    cin>>p;
    rep(i,0,n-1) cin>>a[i]>>b[i];
    ld l=0.000,h=inf2,eps=0.0000001;
    while((h-l)>eps){
        ld x=(l+h)/2.0;
        ld y=p*x;
        rep(i,0,n-1){
            ld temp=a[i]*x-b[i];
            if(temp>=0.0){
                temp=temp+0.000001;
                if(y>=temp){
                    y-=temp;
                }
                else{
                    y=-1.0; break;
                }
            }
        }
        if(y>=0.0) l=x;
        else h=x;
    }
    precision(4);
    if(fabs(l-inf2)<eps) cout<<"-1\n";
    else cout<<l<<'\n';
    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-6;
const int maxn=1e5+5;
double p, sum, sum_t, ans;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool ok2(double x){
    double all=p*x;
    double need=0;
    for(int i=0;i<n;i++){
        double tmp=d[i].a*x-d[i].b;
        if(tmp>0) need+=tmp;
    }
    return all>=need;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    int inf=0;
    sum_t=1e9;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        inf=1;
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double a[maxn], b[maxn], t[maxn];
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(need*d[i].a>=d[i].b) return false;
        need+=d[i].a*x/(p-d[i].a);
    }
    return need<=x;
}
bool check2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(need*d[i].a>=d[i].b) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].b;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(p>=sum){
        double lt=0, rt=sum_t;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)) {
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(check2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double a[maxn], b[maxn], t[maxn];
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
     //   if(need*d[i].a>=d[i].b) return false;
        need+=d[i].a*x/(p-d[i].a);
    }

//    printf("x=%lf need=%lf\n",x, need);
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
    //    if(need*d[i].a>=d[i].b) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].b;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)) {
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double a[maxn], b[maxn], t[maxn];
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        need+=d[i].a*x/(p-d[i].a);
    }

//    printf("x=%lf need=%lf\n",x, need);
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].b)>=0) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
bool cmp(dev &a, dev &b){
    return a.a>b.a;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n, cmp);
    int inf=0;
    sum_t=1e18;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        sort(d,d+n);
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double a[maxn], b[maxn], t[maxn];
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        need+=d[i].a*x/(p-d[i].a);
    }

//    printf("x=%lf need=%lf\n",x, need);
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].b)>=0) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double a[maxn], b[maxn], t[maxn];
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++)
        need+=d[i].a*x/(p-d[i].a);
    return need<=x;
}
bool check2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].b;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(p>=sum){
        double lt=0, rt=100000;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)) {
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(check2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-6;
const int maxn=1e5+5;
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
    //    if(dcmp(need-d[i].t)>=0) return false;
        need+=d[i].a*x/p;
    }
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-6;
const int maxn=1e5+5;
double p, sum, sum_t, ans;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double all=p*x;
    double tmp=0;
    for(int i=0;i<n;i++){
        tmp+=max(0.0, d[i].a*x);
    }
    return all>=tmp;
}
bool ok2(double x){
    double all=p*x;
    double need=0;
    for(int i=0;i<n;i++){
        double tmp=d[i].a*x-d[i].b;
        if(tmp>0) need+=tmp;
    }
    return all>=need;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    int inf=0;
    sum_t=1e9;
    if(n==1&&p>=d[0].a) inf=1;
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        need+=d[i].a*x/(p-d[i].a);
    }

//    printf("x=%lf need=%lf\n",x, need);
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
bool cmp(dev &a, dev &b){
    return a.a>b.a;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n, cmp);
    int inf=0;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        sort(d,d+n);
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double a[maxn], b[maxn], t[maxn];
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
     //   if(need*d[i].a>=d[i].b) return false;
        need+=d[i].a*x/(p-d[i].a);
    }

//    printf("x=%lf need=%lf\n",x, need);
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
    //    if(need*d[i].a>=d[i].b) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-8;
const int maxn=1e5+5;
double a[maxn], b[maxn], t[maxn];
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        need+=d[i].a*x/(p-d[i].a);
    }

//    printf("x=%lf need=%lf\n",x, need);
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].b)>=0) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
bool cmp(dev &a, dev &b){
    return a.a>b.a;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n, cmp);
    int inf=0;
    sum_t=1e9+5;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        sort(d,d+n);
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-6;
const int maxn=1e5+5;
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        need+=d[i].a*x/p;
    }
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        if(dcmp(need-d[i].t)>=0) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<numeric>
using namespace std;
#define PI acos(-1.0)
#define LL long long
#define ULL unsigned long long
#define LS (root<<1)
#define RS ((root<<1)|1)
#define LSON LS,l,mid
#define RSON RS,(mid+1),r
#define MID mid=((l+r)/2)
#define PR pair<int,int>
#define se second
#define MP make_pair
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");
#define MOD 1000000007
#define idx(x) x-'a'
template<class T> T f_max(T a, T b){ return a > b ? a : b; }
template<class T> T f_min(T a, T b){ return a < b ? a : b; }
template<class T> T f_abs(T a){ return a > 0 ? a : -a; }
template<class T> T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void f_swap(T &a, T &b){ T c; c = a; a = b; b = c; }
// 0x3f3f3f3f3f3f3f3f
// 0x3f3f3f3f
const double eps=1e-6;
const int maxn=1e5+5;
double p, sum, sum_t;
int n;
struct dev{
    double a, b, t;
    bool operator <(const dev &rhs)const{
        return t<rhs.t;
    }
};
dev d[maxn];
int dcmp(double x){
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}
bool check(double x){
    double need=0;
    for(int i=0;i<n;i++){
        //if(dcmp(need-d[i].t)>=0) return false;
        need+=d[i].a*x/p;
    }
    return need<=x;
}
bool ok2(double x){
    double need=0;
    for(int i=0;i<n;i++){
        //if(dcmp(need-d[i].t)>=0) return false;
        double tmp=(d[i].a*x-d[i].b)/p;
        if(tmp>0) need+=tmp;
    }
    return need<=x;
}
int main(){

    scanf("%d%lf",&n, &p);
    sum=0; sum_t=0;
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&d[i].a, &d[i].b);
        d[i].t=d[i].b/d[i].a;
        sum+=d[i].a;
        sum_t+=d[i].t;
    }
    sort(d,d+n);
    int inf=0;
    if(n==1&&p>=d[0].a) inf=1;
    else if(p>=sum){
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;

            if(check(mt)){
                inf=1;
                break;
            }
            else lt=mt;
        }
        if(check((lt+rt)/2)) inf=1;
    }
    if(inf) puts("-1");
    else{
        double lt=0, rt=sum_t+1;
        while(dcmp(lt-rt)<0){
            double mt=(lt+rt)/2;
            if(ok2(mt)) lt=mt;
            else rt=mt;
        }
        printf("%.8lf\n",(lt+rt)/2);
    }

    return 0;
}