Consider a system of n water taps all pouring water into the same container. The i-th water tap can be set to deliver any amount of water from 0 to a_{i} ml per second (this amount may be a real number). The water delivered by i-th tap has temperature t_{i}.

If for every $i \in [ 1, n ]$ you set i-th tap to deliver exactly x_{i} ml of water per second, then the resulting temperature of water will be $\frac{\sum_{i = 1}^{n} x_{i} t_{i}}{\sum_{i = 1}^{n} x_{i}}$ (if $\sum_{i = 1}^{n} x_{i} = 0$, then to avoid division by zero we state that the resulting water temperature is 0).

You have to set all the water taps in such a way that the resulting temperature is exactly T. What is the maximum amount of water you may get per second if its temperature has to be T?


-----Input-----

The first line contains two integers n and T (1 ≤ n ≤ 200000, 1 ≤ T ≤ 10^6) — the number of water taps and the desired temperature of water, respectively.

The second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^6) where a_{i} is the maximum amount of water i-th tap can deliver per second.

The third line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 10^6) — the temperature of water each tap delivers.


-----Output-----

Print the maximum possible amount of water with temperature exactly T you can get per second (if it is impossible to obtain water with such temperature, then the answer is considered to be 0).

Your answer is considered correct if its absolute or relative error doesn't exceed 10^{ - 6}.


-----Examples-----
Input
2 100
3 10
50 150

Output
6.000000000000000

Input
3 9
5 5 30
6 6 10

Output
40.000000000000000

Input
2 12
1 3
10 15

Output
1.666666666666667

Difficulty: interview

Starter code:

Solutions:
# import getpass
import sys
import math

EPS = 0.000000001

files = True
debug = False

# if getpass.getuser() == 'frohenk' and files:
#     debug = True
#     sys.stdin = open("test.in")
#     # sys.stdout = open('test.out', 'w')
# elif files:
#     # fname = "gift"
#     # sys.stdin = open("%s.in" % fname)
#     # sys.stdout = open('%s.out' % fname, 'w')
#     pass


def lcm(a, b):
    return a * b // math.gcd(a, b)


def ria():
    return [int(i) for i in input().split()]


def range_sum(a, b):
    ass = (((b - a + 1) // 2) * (a + b))
    if (a - b) % 2 == 0:
        ass += (b - a + 2) // 2
    return ass


def comba(n, x):
    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)


def eq(a, b):
    return abs(a - b) <= EPS


n, ta = ria()
vs = ria()
ts = ria()
ks = []
up = 0
down = sum(vs)
for i in range(n):
    ks.append((ts[i], vs[i]))
    up += ts[i] * vs[i]
ks.sort()
if up / down > ta:

    if min(ts)>ta:
        print('0')
        return

    ks = list(reversed(ks))

    for t, v in ks:
        if down == 0:
            print(0)
            return
        if eq(up / down, ta):
            print(down)
            return
        if (up - t * v) / (down - v) > ta or eq((up - t * v) / (down - v), ta):
            up -= t * v
            down -= v
            continue

        l, r = 0, v

        up -= t * v
        down -= v

        while r - l > EPS:
            m = (l + r)/2
            if (up + t * m) / (down + m)>ta:
                r=m
            else:
                l=m
        print(down+l)
        return


else:

    if max(ts) < ta:
        print('0')
        return
    for t, v in ks:
        if down == 0:
            print(0)
            return
        if eq(up / down, ta):
            print(down)
            return
        if (up - t * v) / (down - v) < ta or eq((up - t * v) / (down - v), ta):
            up -= t * v
            down -= v
            continue

        l, r = 0, v

        up -= t * v
        down -= v

        while r - l > EPS:
            m = (l + r)/2
            if (up + t * m) / (down + m)<ta:
                r=m
            else:
                l=m
        print(down+l)
        return


rd = lambda: list(map(int, input().split()))
n, t = rd()
a = list(rd())
b = list(rd())
x = [[b[i], a[i]] for i in range(n)]
x.sort()
tot, val = sum(a), 0
for i in range(n):
    val += (t - x[i][0]) * x[i][1]
if val < 0:
    for i in range(n - 1, -1, -1):
        if val - x[i][1] * (t - x[i][0]) >= 0:
            tot -= val / (t - x[i][0])
            val = 0
            break
        tot -= x[i][1]
        val -= (t - x[i][0]) * x[i][1]
if val > 0:
    for i in range(n):
        if val - x[i][1] * (t - x[i][0]) <= 0:
            tot -= val / (t - x[i][0])
            val = 0
            break
        tot -= x[i][1]
        val -= (t - x[i][0]) * x[i][1]
print('%.12f' % tot)



#!/usr/bin/env python3

import sys

[n, T] = list(map(int, sys.stdin.readline().strip().split()))
ais = list(map(int, sys.stdin.readline().strip().split()))
tis = list(map(int, sys.stdin.readline().strip().split()))

i_0 = [i for i in range(n) if tis[i] == T]
i_hot = [i for i in range(n) if tis[i] > T]
i_cold = [i for i in range(n) if tis[i] < T]

tis = [abs(ti - T) for ti in tis]
w_hot = sum(ais[i] * tis[i] for i in i_hot)
w_cold = sum(ais[i] * tis[i] for i in i_cold)

if w_hot > w_cold:
	w_hot, w_cold = w_cold, w_hot
	i_hot, i_cold = i_cold, i_hot

x_max = sum(ais[i] for i in i_0) + sum(ais[i] for i in i_hot)

w = w_hot
i_cold.sort(key=lambda _k: tis[_k])
for i in i_cold:
	a, t = ais[i], tis[i]
	if a * t <= w:
		w -= a * t
		x_max += a
	else:
		x_max = x_max + float(w) / t
		w = 0
		break


print(float(x_max))


R = lambda : map(int, input().split())
n, temp = R()
a = list(R())
t = list(R())
v = sorted([(t[i]-temp,a[i]) for i in range(n)])

r = sum([v[i][1] for i in range(n) if v[i][0]==0])
pos = sum([v[i][0]*v[i][1] for i in range(n) if v[i][0]>0])
neg = sum([abs(v[i][0])*v[i][1] for i in range(n) if v[i][0]<0])

pa = sum([v[i][1] for i in range(n) if v[i][0]>0])
na = sum([v[i][1] for i in range(n) if v[i][0]<0])

if pos == 0 or neg == 0:
    print(r); return;

for i in range(n):
    if v[i][0] >= 0:
        stn = i-1; break;

for i in range(n):
    if v[i][0] > 0:
        stp = i; break;

if neg<pos:
    r += na
    rem = neg * 1.0
    for i in range(stp,n):
        if v[i][0]*v[i][1]>=rem:
            r += rem / v[i][0]
            rem = 0
        else:
            r += v[i][1]
            rem -= v[i][0]*v[i][1]
else:
    r += pa
    rem = pos * 1.0
    for i in reversed(range(stn+1)):
        if abs(v[i][0])*v[i][1]>=rem:
            r += rem / abs(v[i][0])
            rem = 0
        else:
            r += v[i][1]
            rem -= abs(v[i][0])*v[i][1]

print(r)

n, nt = map(int, input().split())
a = list(map(int, input().split()))
t = list(map(int, input().split()))
c = 0
ans = 0
l = []
r = []
for i in range(n):
    if t[i] < nt:
        l.append([nt - t[i], a[i]])
    if t[i] > nt:
        r.append([t[i] - nt, a[i]])
    if t[i] == nt:
        ans += a[i]
l = sorted(l, key=lambda x: x[0])
r = sorted(r, key=lambda x: x[0])
il = 0
ir = 0
lv = 0.0
rv = 0.0
lvv = 0.0
rvv = 0.0
while 1:
    if lv <= rv:
        if il ==len(l):
            break
        lv += l[il][0] * l[il][1]
        lvv += l[il][1]
        il += 1
    else:
        if ir ==len(r):
            break
        rv += r[ir][0] * r[ir][1]
        rvv += r[ir][1]
        ir += 1
if rv < lv:
    lv -= l[il - 1][0] * l[il - 1][1]
    lvv -= l[il - 1][1]
    lvv += (rv - lv) / l[il - 1][0]
elif lv < rv:
    rv -= r[ir - 1][0] * r[ir - 1][1]
    rvv -= r[ir - 1][1]
    rvv += (lv - rv) / r[ir - 1][0]

ans += rvv
ans += lvv
print("%.8f" % ans)

rd = lambda: list(map(int, input().split()))
n, t = rd()
a = list(rd())
b = list(rd())
x = [[b[i], a[i]] for i in range(n)]
x.sort()
tot, val = sum(a), 0
for i in range(n):
    val += (t - x[i][0]) * x[i][1]
if val:
    f = 2 * (val > 0) - 1
    for i in range(n)[::f]:
        if f * (val - x[i][1] * (t - x[i][0])) <= 0:
            tot -= val / (t - x[i][0])
            break
        tot -= x[i][1]
        val -= (t - x[i][0]) * x[i][1]
print(tot)


n,t=list(map(int,input().strip().split(' ')))
x= list(map(int,input().strip().split(' ')))

temp= list(map(int,input().strip().split(' ')))
for i in range(n):
  temp[i]-=t
pos = []
neg = []
ans = 0
negsum = 0
possum = 0
for i in range(n):
  if(temp[i]<0):
    negsum+=temp[i]*x[i]
    neg.append([temp[i]*-1,x[i]])
  elif(temp[i]>0):
    possum+=temp[i]*x[i]
    pos.append([temp[i],x[i]])
  else:
    ans+=x[i]
if(abs(negsum)>possum):
  for i in pos:
    ans+=i[1]
  neg.sort()
  for i in neg:
    t = i[0]*i[1]*-1
    if(t+possum<0):
      ans+= (possum*1.0/i[0])
      break
    else:
      ans+=i[1]
      possum+=t
  print(ans)
elif(possum>abs(negsum)):
  for i in neg:
    ans+=i[1]
  pos.sort()
  for i in pos:
    t = i[0]*i[1]
    if(t+negsum>0):
      ans+= abs(negsum*1.0/i[0])
      break
    else:
      ans+=i[1]
      negsum+=t
  print(ans)
else:
  print(sum(x))





def f(t, x):
    for i in range(1, len(t) + 1):
        ps[i] = ps[i - 1] + t[i - 1][0] * t[i - 1][1]
    l = 0
    r = len(t) + 1
    while l < r:
        s = (l + r) // 2
        if ps[s] <= x:
            l = s + 1
        else:
            r = s
    return l - 1

n , T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
t = [(int(x) - T,  a[i]) for i, x in enumerate(input().split())]

tp = list(sorted([e for e in t if e[0] > 0]))
tm = list(sorted([(-x[0], x[1]) for x in ([e for e in t if e[0] < 0])]))
ep = sum(e[0] * e[1] for e in tp)
em = sum(e[0] * e[1] for e in tm)
ps = [0] * (n + 1)
res = sum([e[1] for e in [e for e in t if e[0] == 0]])
if ep > 0 and em > 0:
    if ep < em:
        it = f(tm, ep)

        res += sum([e[1] for e in tp])
        res += sum([e[1] for e in tm[:it]])
        if  it < len(tm):
            res += (ep - ps[it]) / tm[it][0]
    else:
        it = f(tp, em)
        res += sum([e[1] for e in tm])
        res += sum([e[1] for e in tp[:it]])
        if  it < len(tp):
            res += (em - ps[it]) / tp[it][0]
print(res)



n,T=map(int,input().split())
a=list(map(int,input().split()))
x=list(map(int,input().split()))
m=[]
q=0
for i in range(n):
    m+=[[x[i],a[i]]]
    q+=a[i]*x[i]
asu=sum(a)
try:
    if q/asu==T:
        print(asu)
    elif q/asu>T:
        m.sort()
        asu-=m[-1][1]
        q-=m[-1][0]*m[-1][1]
        while q/asu>T:
            m.pop()
            asu-=m[-1][1]
            q-=m[-1][0]*m[-1][1]
        print(asu+m[-1][1]*((T*asu-q)/(m[-1][1]*m[-1][0]-T*m[-1][1])))
    else:
        m.sort(reverse=True)
        asu-=m[-1][1]
        q-=m[-1][0]*m[-1][1]
        while q/asu<T:
            m.pop()
            asu-=m[-1][1]
            q-=m[-1][0]*m[-1][1]
        print(asu+m[-1][1]*((T*asu-q)/(m[-1][1]*m[-1][0]-T*m[-1][1])))
except ZeroDivisionError:
    print(0)

rd = lambda: list(map(int, input().split()))
n, t = rd()
a, b = rd(), rd()
x = [[t - b[i], a[i]] for i in range(n)]
x.sort()
c, v = sum(a), sum(i * j for i, j in x)
if v:
    f = 2 * (v < 0) - 1
    for i in range(n)[::f]:
        if f * (v - x[i][1] * x[i][0]) >= 0:
            c -= v / x[i][0]
            break
        c -= x[i][1]
        v -= x[i][0] * x[i][1]
print(c)



n,t=list(map(int,input().split()))
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l=[[l2[i],l1[i]] for i in range(n)]
l.sort()
s1=sum([l[i][0]*l[i][1] for i in range(n)])
s2=sum(l1)
s=s1/s2
f=n-1
d=0

if s<t:
    while s<t and d<n:
        s2=s2-l[d][1]
        s1=s1-l[d][0]*l[d][1]
        if s2!=0:
            s=s1/s2
        if s>t:
            s2+=(s2*t-s1)/(l[d][0]-t)
            break
        elif s==t:
            break
        else:
            d+=1
    
elif s>t:
    while s>t and f>=0:
        s2=s2-l[f][1]
        s1=s1-l[f][0]*l[f][1]
        if s2!=0:
            s=s1/s2
        if s<t:
            s2+=(t*s2-s1)/(l[f][0]-t)
            break
        elif s==t:
            break
        else:
            f-=1
print(s2)
        
    


R=lambda:list(map(int,input().split()))
n,t=R()
a=R()
b=R()
x=[[t-b[i],a[i]] for i in range(n)]
x.sort()
c,v=sum(a),sum(i*j for i,j in x)
if v:
    f=2*(v<0)-1
    for i in range(n)[::f]:
        if f*(v-x[i][1]*x[i][0])>=0:
            c-=v/x[i][0]
            break
        c-=x[i][1]
        v-=x[i][0]*x[i][1]
print(c)


n, T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
tp, tm = [], []
s = 0
for i, x in enumerate(input().split()):
    dt = int(x)-T
    if dt > 0:
        tp.append([dt, a[i]])
    elif dt < 0:
        tm.append([-dt, a[i]])
    else:
        s+=a[i]

tp.sort()
tm.sort()
i,j= 0, 0
while i < len(tp) and j < len(tm):
    qp = tp[i][0]*tp[i][1]
    qm = tm[j][0]*tm[j][1]
    if qp>qm:
        r = tm[j][0]/tp[i][0]
        s += (1+r)*tm[j][1]
        tp[i][1] -= tm[j][1]*r
        j += 1
    else:
        r = tp[i][0]/tm[j][0]
        s += (1+r)*tp[i][1]
        tm[j][1] -= tp[i][1]*r
        i += 1
print(s)


def get_max_volume(sources, required_temperature):
    """
    :param List[Set[int]]sources:
    :param int required_temperature:
    :return: float
    """
    max_volume = 0.
    temp = 0
    higher_sources = []
    lower_sources = []

    for volume, temperature in sources:
        delta_temp = temperature - required_temperature
        if delta_temp > 0:
            higher_sources.append((volume, delta_temp))
        elif delta_temp < 0:
            lower_sources.append((volume, delta_temp))
        max_volume += volume
        temp += volume * delta_temp
    higher_sources.sort(key=lambda v: v[1])
    lower_sources.sort(key=lambda v: -v[1])
    while abs(temp / max_volume) >= 1e-6 \
            and (len(lower_sources) > 0 or temp >= 0)\
            and (len(higher_sources) > 0 or temp <= 0):
        if temp < 0:
            volume, delta_temp = lower_sources.pop()
            if temp - delta_temp * volume >= 0:
                required_volume = temp / delta_temp
                return max_volume - required_volume
            temp -= delta_temp * volume
            max_volume -= volume
        else:
            volume, delta_temp = higher_sources.pop()
            if temp - delta_temp * volume <= 0:
                required_volume = temp / delta_temp
                return max_volume - required_volume
            temp -= delta_temp * volume
            max_volume -= volume

    if abs(temp / max_volume) < 1e-6:
        return max_volume

    return 0.


n, t = list(map(int, input().split()))
vs = input().split()
ts = input().split()
ss = [(int(vs[i]), int(ts[i])) for i in range(n)]
print(get_max_volume(ss, t))


n, T = list(map(int, input().split(' ')))
r = list()
r.append(list(map(int, input().split(' '))))
r.append(list(map(int, input().split(' '))))
r.append(list())
for i in range(len(r[0])):
	r[2].append((r[0][i], r[1][i]))
r[2].sort(key=lambda x: x[::-1])
for i in range(n):
	r[0][i] = r[2][i][0]
	r[1][i] = r[2][i][1]

fl = True
tau = sum(r[0]) * T > sum(map(lambda x: x[0] * x[1], r[2]))
if tau:
	r[2].reverse()
	fl = False
tau1 = not tau

summ = list()
proi = list()
su = 0
pr = 0
for i in range(n):
	su += r[2][i][0]
	summ.append(su)
	pr += r[2][i][0] * r[2][i][1]
	proi.append(pr)

lev = 0
pra = n - 1
while lev < n - 1 and ((r[2][lev][1] <= T and fl) or
                       (r[2][lev][1] >= T and not fl)):
	lev += 1
test = lev

while lev != pra:
	tau = tau1
	tau1 = summ[(lev + pra) // 2 - 1] * T > proi[(lev + pra) // 2 - 1]
	if tau == tau1:
		lev = (lev + pra) // 2 + 1
	else:
		pra = (lev + pra) // 2
		tau1 = not tau1

tau = summ[-1] * T > proi[-1]
tau1 = summ[max(pra - 1, 0)] * T > proi[max(pra - 1, 0)]
if tau != tau1:
	x = ((summ[max(pra - 1, 0)] * T) - proi[max(pra - 1, 0)]) / (
	    r[2][pra][1] - T)
	x = summ[max(pra - 1, 0)] + x
	print(x)
else:
	tau = tau1
	tau1 = summ[max(lev - 2, 0)] * T > proi[max(lev - 2, 0)]
	if tau != tau1:
		x = ((summ[max(lev - 2, 0)] * T) - proi[max(lev - 2, 0)]) / (
		    r[2][max(lev - 1, 0)][1] - T)
		x = summ[max(lev - 2, 0)] + x
		print(x)
	else:
		x = 0
		if test == 0 or test == 1:
		    if r[2][0][1] == T:
		        x = r[2][0][0]
		else:
		    if r[2][test][1]!=T:
		        test -= 1
		    x = summ[test]
		    while test>-1 and r[2][test][1]==T:
		        test -= 1
		    if test != -1:
		        x -= summ[test]
		print(x)

n, T = map(int, input().split())
v = list(map(int, input().split()))
t = list(map(int, input().split()))
plus, minus = [], []
pr, ans = 0, 0
for i in range(n):
    if t[i] < T:
        minus.append([T - t[i], i])
    elif t[i] > T:
        plus.append([t[i] - T, i])
    else:
        ans += v[i]
max1, max2 = 0, 0
for i in range(len(minus)):
    max1 += minus[i][0] * v[minus[i][1]]
for i in range(len(plus)):
    max2 += plus[i][0] * v[plus[i][1]]
if max1 > max2:
    minus.sort()
    i = 0
    while pr != max2:
        if max2 - pr < v[minus[i][1]] * minus[i][0]:
            ans += (max2 - pr) / minus[i][0]
            pr += max2 - pr
        else:
            ans += v[minus[i][1]]
            pr += v[minus[i][1]] * minus[i][0]
        i += 1
    for i in range(len(plus)):
        ans += v[plus[i][1]]    
else:
    plus.sort()
    i = 0
    while pr != max1:
        if max1 - pr < v[plus[i][1]] * plus[i][0]:
            ans += (max1 - pr) / plus[i][0]
            pr += max1 - pr
        else:
            ans += v[plus[i][1]]
            pr += v[plus[i][1]] * plus[i][0]
        i += 1
    for i in range(len(minus)):
        ans += v[minus[i][1]]
print(ans)

rd = lambda: map(int, input().split())
n, t = rd()
a = list(rd())
b = list(rd())
x = [[b[i], a[i]] for i in range(n)]
x.sort()
tot, val = sum(a), 0
for i in range(n):
    val += (t - x[i][0]) * x[i][1]
if val:
    f = 2 * (val > 0) - 1
    for i in range(n)[::f]:
        if f * (val - x[i][1] * (t - x[i][0])) <= 0:
            tot -= val / (t - x[i][0])
            break
        tot -= x[i][1]
        val -= (t - x[i][0]) * x[i][1]
print(tot)


n,t=map(int,input().strip().split(' '))
x= list(map(int,input().strip().split(' ')))

temp= list(map(int,input().strip().split(' ')))
for i in range(n):
  temp[i]-=t
pos = []
neg = []
ans = 0
negsum = 0
possum = 0
for i in range(n):
  if(temp[i]<0):
    negsum+=temp[i]*x[i]
    neg.append([temp[i]*-1,x[i]])
  elif(temp[i]>0):
    possum+=temp[i]*x[i]
    pos.append([temp[i],x[i]])
  else:
    ans+=x[i]
if(abs(negsum)>possum):
  for i in pos:
    ans+=i[1]
  neg.sort()
  for i in neg:
    t = i[0]*i[1]*-1
    if(t+possum<0):
      ans+= (possum*1.0/i[0])
      break
    else:
      ans+=i[1]
      possum+=t
  print(ans)
elif(possum>abs(negsum)):
  for i in neg:
    ans+=i[1]
  pos.sort()
  for i in pos:
    t = i[0]*i[1]
    if(t+negsum>0):
      ans+= abs(negsum*1.0/i[0])
      break
    else:
      ans+=i[1]
      negsum+=t
  print(ans)
else:
  print(sum(x))

eps = 1e-9
n, T = map(int, input().split())
a = [*map(int, input().split())]
t = [*map(int, input().split())]
l = sorted(zip(t, a))


S = sum(x * y for x, y in l)
V = sum(a)
while l and (S - V * T) > V * eps and l[-1][0] > T:
    x, y = l.pop()
    d = min(y, (S - V * T) / (x - T))
    S -= x * d
    V -= d

l.reverse()
while l and (V * T - S) > V * eps and l[-1][0] < T:
    x, y = l.pop()
    d = min(y, (V * T - S) / (T - x))
    S -= x * d
    V -= d

print(round(V, 7) if abs(S  - V * T) <= V * eps else 0)

n, T = map(int, input().split())
a = [*map(int, input().split())]
t = [*map(int, input().split())]
l = sorted(zip(t, a))


S = sum(x * y for x, y in l)
V = sum(a)
while l and S > V * T and l[-1][0] > T:
    x, y = l.pop()
    d = min(y, (S - V * T) / (x - T))
    S -= x * d
    V -= d

l.reverse()
while l and V * T > S and l[-1][0] < T:
    x, y = l.pop()
    d = min(y, (V * T - S) / (T - x))
    S -= x * d
    V -= d

print(round(V, 7) if S == V * T else 0)

import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')


def solve():
    n, T = nm()
    a = nl()
    t = nl()
    if min(t) > T or max(t) < T:
        print(0)
        return
    g = [(t[i] - T, i) for i in range(n)]
    h = sum((t[i] - T)*a[i] for i in range(n))
    ans = sum(a)
    if h < 0:
        g.sort()
        for x, i in g:
            if h < x * a[i]:
                ans -= a[i]
                h -= x * a[i]
            else:
                if h and x != 0:
                    ans -= h / x
                break
    elif h > 0:
        g.sort(reverse=True)
        for x, i in g:
            if h > x * a[i]:
                ans -= a[i]
                h -= x * a[i]
            else:
                if h and x != 0:
                    ans -= h / x
                break
    print(ans)
    return

solve()

# T = ni()
# for _ in range(T):
#     solve()


import sys
input = sys.stdin.readline


n, T = map(int, input().split())
a = list(map(int, input().split()))
t = list(map(int, input().split()))


for i in range(n):
    t[i] -= T

lower = []
upper = []
max_lower = 0
max_upper = 0
ans = 0
for i in range(n):
    if t[i] == 0:
        ans += a[i]
    elif t[i] < 0:
        lower.append((-t[i], a[i]))
        max_lower += abs(a[i] * t[i])
    else:
        upper.append((t[i], a[i]))
        max_upper += abs(a[i] * t[i])

max_heat = min(max_upper, max_lower)
lower.sort()
upper.sort()

tmp = 0
for ti, ai in lower:
    if tmp + ti * ai < max_heat:
        ans += ai
        tmp += ti * ai
    else:
        ans += (max_heat - tmp) / ti
        tmp = max_heat
tmp = 0
for ti, ai in upper:
    if tmp + ti * ai < max_heat:
        ans += ai
        tmp += ti * ai
    else:
        ans += (max_heat - tmp) / ti
        tmp = max_heat
print(ans)

import sys
from operator import lt, gt, le, ge, itemgetter

n, t = list(map(int, input().split()))
a = list(zip(list(map(int, input().split())), list(map(int, input().split()))))

nume = sum(a[i][0]*a[i][1] for i in range(n))
deno = sum(a[i][0] for i in range(n))

if nume / deno > t:
    op1, op2, rev = gt, le, False
else:
    op1, op2, rev = lt, ge, True

a.sort(key=itemgetter(1), reverse=rev)

while len(a) > 1 and op1((nume - a[-1][0]*a[-1][1]) / (deno - a[-1][0]), t):
    nume -= a[-1][0] * a[-1][1]
    deno -= a[-1][0]
    a.pop()

nume -= a[-1][0] * a[-1][1]
deno -= a[-1][0]
ok, ng = 0.0, float(a[-1][0])

for _ in range(50):
    mid = (ok + ng) / 2
    if op2((nume + mid * a[-1][1]) / (deno + mid), t):
        ok = mid
    else:
        ng = mid

print(deno + ok)