You are given an array arr of length N, representing money with N customers. The i-th customer has arri rupees. There is another array cost of length M, representing the cost of M items in a store. The j-th item costs costj rupees. The store offers some discount money d which any customer can use to buy an item. Each customer can buy only one item and cannot use his money to buy an item for any other customer.
Task
Determine the maximum number of customers who can buy an item and the minimum total sum of customers’ money spent to achieve maximum customers with an item.
Notes
Example
Assumptions
Approach
Initially, we have discount money equals 100.
Therefore the answer is [2 90].
Function Description
Complete the function maxCustomers provided in the editor. The function takes the following parameters and returns an array consisting of 2 integers, the maximum number of customers with items, and the minimum total customers' money spent:
Input format
Note: This is the input format you must use to provide custom input (available above the Compile and Test button).
Output format
Print two space-separated numbers, the maximum number of customers who can buy an item and the minimum total customers' money needed for buying the maximum number of items.
Constraints
1≤N≤105
1≤M≤105
0≤d≤109
1≤arri≤104 ∀ i∈[1,N]
1≤costj≤109 ∀ j∈[1,M]
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.
Given
Approach
Initially we have discount money equals 50.
Therefore the answer is [2 30].