Problem: 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 ai ml per second (this amount may be a real number). The water delivered by i-th tap has temperature ti.

If for every <image> you set i-th tap to deliver exactly xi ml of water per second, then the resulting temperature of water will be <image> (if <image>, 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 ≤ 106) — the number of water taps and the desired temperature of water, respectively.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) where ai is the maximum amount of water i-th tap can deliver per second.

The third line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 106) — 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

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class EEdu40
{
    public static void main(String[] args)
    {
        new EEdu40(System.in, System.out);
    }

    private static class Solver implements Runnable
    {
        int n;
        double target;
        Tap[] taps;
        InputReader in;
        PrintWriter out;

        void solve() throws IOException
        {
            n = in.nextInt();
            target = in.nextInt();
            taps = new Tap[n];

            for (int i = 0; i < n; i++)
                taps[i] = new Tap(in.nextInt());

            for (int i = 0; i < n; i++)
                taps[i].temperature = in.nextInt();

            Arrays.sort(taps, (a, b) ->
            {
                if (a.temperature == b.temperature)
                    return Double.compare(a.quantity, b.quantity);

                return Double.compare(a.temperature, b.temperature);
            });

            double temp = 0.0;
            double[] leftCumQuantity = new double[n];
            double[] rightCumQuantity = new double[n];
            double[] pre = new double[n];
            double[] suf = new double[n];

            pre[0] = taps[0].quantity * taps[0].temperature;
            suf[n - 1] = taps[n - 1].quantity * taps[n - 1].temperature;
            leftCumQuantity[0] = taps[0].quantity;
            rightCumQuantity[n - 1] = taps[n - 1].quantity;

            for (int i = 1; i < n; i++)
                pre[i] = pre[i - 1] + taps[i].quantity * taps[i].temperature;

            for (int i = n - 2; i >= 0; i--)
                suf[i] = suf[i + 1] + taps[i].quantity * taps[i].temperature;

            for (int i = 1; i < n; i++)
                leftCumQuantity[i] = leftCumQuantity[i - 1] + taps[i].quantity;

            for (int i = n - 2; i >= 0; i--)
                rightCumQuantity[i] = rightCumQuantity[i + 1] + taps[i].quantity;

            for (int i = 0; i < n; i++)
                temp += taps[i].quantity * taps[i].temperature;

            temp /= leftCumQuantity[n - 1];

/*            System.out.println("temp : " + temp);
            System.out.println("taps : " + Arrays.toString(taps));
            System.out.println("lCQ : " + Arrays.toString(leftCumQuantity));
            System.out.println("rCQ : " + Arrays.toString(rightCumQuantity));
            System.out.println("pre : " + Arrays.toString(pre));
            System.out.println("suf : " + Arrays.toString(suf));*/

            if (temp >= target)
            {
                int low = 0;
                int high = n - 1;
                int ind = -1;

                while (low <= high)
                {
                    int mid = low + high >> 1;

                    if (pre[mid] / leftCumQuantity[mid] == target)
                    {
                        if (mid < n - 1 && pre[mid + 1] / leftCumQuantity[mid + 1] == target)
                        {
                            low = mid + 1;

                            continue;
                        }

                        ind = mid;
//                        System.out.println("setting ind as : " + ind);

                        break;
                    }
                    else if (pre[mid] / leftCumQuantity[mid] > target)
                    {
//                        System.out.println("mid : " + mid + ", pre[mid - 1] / lCQ[mid - 1] : " + (pre[mid - 1] /
//                                leftCumQuantity[mid - 1]));

                        if (mid == 0 || pre[mid - 1] / leftCumQuantity[mid - 1] < target)
                        {
                            ind = mid;

                            break;
                        }

                        high = mid - 1;
                    }
                    else
                        low = mid + 1;
                }

                if (ind == -1)
                {
                    print(0);

                    return;
                }

                double prevQuantity = (ind > 0 ? leftCumQuantity[ind - 1] : 0);
                double prevTemp = (prevQuantity > 0 ? (ind > 0 ? pre[ind - 1] : 0) / prevQuantity : 0);
                double requiredQuantity = findRequiredQuantity(prevQuantity, prevTemp, taps[ind].temperature);

                requiredQuantity = (requiredQuantity == Double.POSITIVE_INFINITY ? taps[ind].quantity :
                        requiredQuantity);

/*                System.out.println("ind : " + ind);
                System.out.println("prevQuantity : " + prevQuantity + ", prevTemp : " + prevTemp + ", reqQuantity : "
                        + requiredQuantity);*/

                print(prevQuantity + requiredQuantity);
            }
            else
            {
                int low = 0;
                int high = n - 1;
                int ind = -1;

                while (low <= high)
                {
                    int mid = low + high >> 1;

                    if (suf[mid] / rightCumQuantity[mid] == target)
                    {
                        if (mid > 0 && suf[mid - 1] / rightCumQuantity[mid - 1] == target)
                        {
                            high = mid - 1;

                            continue;
                        }

                        ind = mid;

                        break;
                    }
                    else if (suf[mid] / rightCumQuantity[mid] < target)
                    {
                        if (mid == n - 1 || suf[mid + 1] / rightCumQuantity[mid + 1] > target)
                        {
                            ind = mid;

                            break;
                        }

                        low = mid + 1;
                    }
                    else
                        high = mid - 1;
                }

                if (ind == -1)
                {
                    print(0);

                    return;
                }

                double prevQuantity = (ind < n - 1 ? rightCumQuantity[ind + 1] : 0);
                double prevTemp = (prevQuantity > 0 ? (ind < n - 1 ? suf[ind + 1] : 0) / prevQuantity : 0);
                double requiredQuantity = findRequiredQuantity(prevQuantity, prevTemp, taps[ind].temperature);

/*                System.out.println("ind : " + ind);
                System.out.println("prevQuantity : " + prevQuantity + ", prevTemp : " + prevTemp + ", reqQuantity : "
                        + requiredQuantity);*/
                requiredQuantity = (requiredQuantity == Double.POSITIVE_INFINITY ? taps[ind].quantity :
                        requiredQuantity);
                print(prevQuantity + requiredQuantity);
            }
        }

        void solve2() throws IOException
        {
            n = in.nextInt();
            target = in.nextInt();
            taps = new Tap[n];

            for (int i = 0; i < n; i++)
                taps[i] = new Tap(in.nextInt());

            for (int i = 0; i < n; i++)
                taps[i].temperature = in.nextInt();

            Arrays.sort(taps, (a, b) ->
            {
                if (a.temperature == b.temperature)
                    return Double.compare(a.quantity, b.quantity);

                return Double.compare(a.temperature, b.temperature);
            });

            if (taps[n - 1].temperature < target)
            {
                print(0);

                return;
            }

            int left = 0;
            int right = n - 1;
            double totalVol = 0.0;

            while (left <= right)
            {
                if (taps[left].temperature > target || taps[right].temperature < target)
                    break;

                double rQ = findRequiredQuantity(taps[left].quantity, taps[left].temperature, taps[right].temperature);

                System.out.println("rQ : " + rQ);

                if (left == right)
                {
                    if (taps[left].temperature == target)
                        totalVol += taps[left].quantity;

                    break;
                }

                if (rQ > taps[right].quantity)
                {
                    double lQ = findRequiredQuantity(taps[right].quantity, taps[right].temperature, taps[left]
                            .temperature);

                    System.out.println("lQ : " + lQ);

                    taps[left].quantity -= lQ;
                    totalVol += lQ + taps[right].quantity;
                    right--;
                }
                else
                {
                    if (rQ < 0)
                    {
                        System.out.println("lTap : " + taps[left] + ", rTemp : " + taps[right].temperature);
                    }

                    taps[right].quantity -= rQ;
                    totalVol += rQ + taps[left].quantity;
                    left++;
                }

//                System.out.println("l : " + left + ", r : " + right + ", tap[l] : " + taps[left] + ", tap[r] : " +
//                        taps[right]);
            }

            print(totalVol);
        }

        void print(double ans)
        {
            out.printf("%.12f\n", ans);
        }

        double findRequiredQuantity(double lQ, double lT, double rT)
        {
            if (target - rT == 0)
            {
                return Double.POSITIVE_INFINITY;
//                System.out.println("returning 0.0");
//                return 0.0;
            }

            return lQ * ((lT - target) / (target - rT));
        }

        class Tap
        {
            double quantity, temperature;

            Tap(double quantity)
            {
                this.quantity = quantity;
            }

            @Override
            public String toString()
            {
                return "qty : " + quantity + ", temp : " + temperature + "\n";
            }

        }

        Solver(InputReader in, PrintWriter out)
        {
            this.in = in;
            this.out = out;
        }

        @Override
        public void run()
        {
            try
            {
                solve();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }

    }

    private static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        int nextInt()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        void close()
        {
            try
            {
                stream.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }

        InputReader(InputStream stream)
        {
            this.stream = stream;
        }

    }

    public EEdu40(InputStream inputStream, OutputStream outputStream)
    {
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Thread thread = new Thread(null, new Solver(in, out), "Solver", 1 << 29);

        try
        {
            thread.start();
            thread.join();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }

        in.close();
        out.flush();
        out.close();
    }

}