Problem:
Score: 500 points

Problem Statement

Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.

In the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:

A team should assign one member to each food, and should not assign the same member to multiple foods.

It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.

The score of a team is the longest time it takes for an individual member to finish the food.

Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.

What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

0 \leq K \leq 10^{18}

1 \leq A_i \leq 10^6\ (1 \leq i \leq N)

1 \leq F_i \leq 10^6\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N
F_1 F_2 ... F_N

Output

Print the minimum possible score of the team.

Sample Input 1

3 5
4 2 1
2 3 1

Sample Output 1

2

They can achieve the score of 2, as follows:

Member 1 does 4 sets of training and eats Food 2 in (4-4) \times 3 = 0 seconds.

Member 2 does 1 set of training and eats Food 3 in (2-1) \times 1 = 1 second.

Member 3 does 0 sets of training and eats Food 1 in (1-0) \times 2 = 2 seconds.

They cannot achieve a score of less than 2, so the answer is 2.

Sample Input 2

3 8
4 2 1
2 3 1

Sample Output 2

0

They can choose not to do exactly K sets of training.

Sample Input 3

11 14
3 1 4 1 5 9 2 6 5 3 5
8 9 7 9 3 2 3 8 4 6 2

Sample Output 3

12

Solution in C# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;


class Program
{
    static long max = 10000000000;
    static void Main(string[] args)
    {
        var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NK[0];
        var K = NK[1];

        
        var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var F = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        Array.Sort(A);
        Array.Sort(F);
        Array.Reverse(F);
        var pq = new PriorityQueue<Asign>();
        for (int i = 0; i < N; i++)
        {
            var asign = new Asign(A[i], F[i]);
            pq.Enqueue(asign);
        }

        for (int i = 0; i < K; i++)
        {
            var tmp = pq.Dequeue();
            tmp.cost--;
            pq.Enqueue(tmp);
        }
        var ans = pq.Dequeue();
        Console.WriteLine(Asign.Cost(ans));

    }

    


}

public class PriorityQueue<T> : IEnumerable<T>
{
    private readonly List<T> _data = new List<T>();
    private readonly IComparer<T> _comparer;
    private readonly bool _isDescending;

    public PriorityQueue(IComparer<T> comparer, bool isDescending = true)
    {
        _comparer = comparer;
        _isDescending = isDescending;
    }

    public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
        : this(Comparer<T>.Create(comparison), isDescending)
    {
    }

    public PriorityQueue(bool isDescending = true)
        : this(Comparer<T>.Default, isDescending)
    {
    }

    public void Enqueue(T item)
    {
        _data.Add(item);
        var childIndex = _data.Count - 1;
        while (childIndex > 0)
        {
            var parentIndex = (childIndex - 1) / 2;
            if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
                break;
            Swap(childIndex, parentIndex);
            childIndex = parentIndex;
        }
    }

    public T Dequeue()
    {
        var lastIndex = _data.Count - 1;
        var firstItem = _data[0];
        _data[0] = _data[lastIndex];
        _data.RemoveAt(lastIndex--);
        var parentIndex = 0;
        while (true)
        {
            var childIndex = parentIndex * 2 + 1;
            if (childIndex > lastIndex)
                break;
            var rightChild = childIndex + 1;
            if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0)
                childIndex = rightChild;
            if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
                break;
            Swap(parentIndex, childIndex);
            parentIndex = childIndex;
        }
        return firstItem;
    }

    public T Peek()
    {
        return _data[0];
    }

    private void Swap(int a, int b)
    {
        var tmp = _data[a];
        _data[a] = _data[b];
        _data[b] = tmp;
    }

    private int Compare(T a, T b)
    {
        return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
    }

    public int Count => _data.Count;

    public IEnumerator<T> GetEnumerator()
    {
        return _data.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

public struct Asign : IComparable<Asign>
{
    public long cost;
    public long meel;
    public Asign(long vec1, long vec2)
    {
        cost = vec1;
        meel = vec2;
    }

    public static long Cost(Asign vec)
    {
        return vec.cost*vec.meel;
    }
    public int CompareTo(Asign othervec)
    {
        return Cost(this).CompareTo(Cost(othervec));
    }
}

class UnionFind



{



    // 親要素のインデックスを保持する



    // 親要素が存在しない(自身がルートである)とき、マイナスでグループの要素数を持つ



    public long[] Parents { get; set; }



    public UnionFind(long n)



    {



        this.Parents = new long[n];



        for (int i = 0; i < n; i++)



        {



            // 初期状態ではそれぞれが別のグループ(ルートは自分自身)



            // ルートなのでマイナスで要素数(1個)を保持する



            this.Parents[i] = -1;



        }



    }







    // 要素xのルート要素はどれか



    public long Find(long x)



    {



        // 親がマイナスの場合は自分自身がルート



        if (this.Parents[x] < 0) return x;



        // ルートが見つかるまで再帰的に探す



        // 見つかったルートにつなぎかえる



        this.Parents[x] = Find(this.Parents[x]);



        return this.Parents[x];



    }







    // 要素xの属するグループの要素数を取得する



    public long Size(long x)



    {



        // ルート要素を取得して、サイズを取得して返す



        return -this.Parents[this.Find(x)];



    }







    // 要素x, yが同じグループかどうか判定する



    public bool Same(long x, long y)



    {



        return this.Find(x) == this.Find(y);



    }







    // 要素x, yが属するグループを同じグループにまとめる



    public bool Union(long x, long y)



    {



        // x, y のルート



        x = this.Find(x);



        y = this.Find(y);



        // すでに同じグループの場合処理しない



        if (x == y) return false;







        // 要素数が少ないグループを多いほうに書き換えたい



        if (this.Size(x) < this.Size(y))



        {



            var tmp = x;



            x = y;



            y = tmp;



        }



        // まとめる先のグループの要素数を更新



        this.Parents[x] += this.Parents[y];



        // まとめられるグループのルートの親を書き換え



        this.Parents[y] = x;



        return true;



    }



}