Kubernetes is a container orchestration system for automating software deployments, and google wants your help to maintain a highly available Kubernetes cluster.
A Kubernetes cluster is a group of $$$N$$$ nodes (machines) that are used to run applications, each node has a capacity of $$$c_i$$$ pods (a pod is an instance of an application).
We have $$$M$$$ applications and each application has a number of pods $$$a_j$$$ that needs to be run on the cluster to make sure that its users have a nice experience, for example a widely used application like google search must have a lot of instances running, while another small application like google keep doesn't need that much instances to keep users happy.
We define for each application a value called $$$availability_j$$$ which is equal to the minimum number of pods from the application $$$j$$$ running on the same node after distrubution for example:
Here we have 3 nodes with capacities $$$5,4,5$$$ respectively and 3 applications:
Now your job is determine the maximum possible value for $$$\min_{1 \le j \le M}(availability_j)$$$
Note: Its guaranteed that all applications can be deployed in the cluster
The first line of the input contains $$$N$$$ and $$$M$$$ ($$$1 \le N,M \le 10^5$$$) the number of nodes, and the number of applications respectively.
The second line of the input contains $$$N$$$ integer representing the capacity of each node ($$$1 \le c_i \le 10^9$$$)
The third line of the input contains $$$M$$$ integer representing the number of pods ($$$1 \le a_j \le 10^9$$$)
Its guaranteed that $$$\sum_{j=1}^{j=M}{a_j} \le \sum_{i=1}^{i=N}{c_i}$$$
Print one integer that represents the maximum possible value for $$$\min_{1 \le j \le M}(availability_j)$$$
3 3 5 4 5 7 5 1
0
4 3 9 9 8 9 8 10 10
2