Difficult Printer
Difficulty: Hard

There are N printers and you have M papers to print. But every paper has a diffculty value (indicated by d[i]), and every printer has an ability value (indicated by a[j]).  The printer j can print the paper i, iff a[j] >= d[i]. 

It takes one second for a printer to print a paper (if it's possible to print that is). Your task is to calculate the minimal seconds (indicated by T) for the printers to print all the papers. 

**Input format:**

N M<br>
a[0] a[1] ... a[n-1]<br>
d[0] d[1] ... d[m-1]<br>

**Output format:**

T

**Constraints:**

0 < N, M, a[i], d[i] < 100000  
Every testcase assures that the answer is finite. 

**Sample Input:**

3 5<br>
7 4 6<br>
1 3 4 6 1<br>

**Sample Output:**

2

**Explanation:**

One possibility.

The printer with ability 7 prints the pages of difficulty 1 first and then difficulty 3 (takes 2s)<br>
The printer with ability 4 prints the pages of difficulty 1 first  and then difficulty 4 (takes 2s)<br>
The printer with ability 6 prints the pages of difficulty 6<br>

The maximum amount of pages a printer had was 2, so the answer is 2.

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
	#include <bits/stdc++.h>
    using namespace std;


    int nPrinters, nPapers;
    vector <int> a, d;

    bool canSolveWithin(int maxTime) {
        int printerIdx = 0, paperIdx = 0;
        while(printerIdx < nPrinters && paperIdx < nPapers) {
            int curTime = 0;
            while(paperIdx < nPapers && curTime < maxTime && d[paperIdx] <= a[printerIdx]) {
                paperIdx++;
                curTime++;
            }
            printerIdx++;
        }

        return paperIdx == nPapers;
    }

    int main()
    {
        cin >> nPrinters >> nPapers;
        int tmp;

        for(int i = 0; i < (int)nPrinters; ++i) {
            cin >> tmp;
            a.push_back(tmp);
        }
        for(int i = 0; i < (int)nPapers; ++i) {
            cin >> tmp;
            d.push_back(tmp);
        }
        sort(a.begin(), a.end());
        reverse(a.begin(), a.end());
        sort(d.begin(), d.end());
        reverse(d.begin(), d.end());
        assert(a[0] >= d[0]);

        int minTime = 1, maxTime = 1e5;

        while(minTime < maxTime) {
            int midTime = (minTime + maxTime) / 2;
            if(canSolveWithin(midTime))
                maxTime = midTime;
            else
                minTime = midTime+1;
        }
        cout << minTime << "\n";


        return 0;
    }