Bob has N workers working under him. The ith worker has some strength Wi. Currently, he has M tasks pending with him. Each task can be assigned to only 1 worker. To do particular task i, Strength Si is required i.e. a task i can be done by a worker only if his strength is greater or equal to Si. Bob has K magical pills, taking a magical pill will increase the strength of a worker by B units. Bob gives pills to workers optimally such that the maximum number of tasks can be done.
Task
Determine the maximum number of tasks that can be completed.
Note: 1-based indexing is followed.
Example
Assumptions
Approach
There are many ways to assign workers to different tasks, some of the ways are:
Function description
Complete the solve function provided in the editor. This function takes the following 6 parameters and returns an integer:
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output format
For each test case in a new line, print the answer representing the maximum number of tasks that can be done.
Constraints
1≤T≤100
1≤K≤105
1≤B≤10
1≤N,M≤104
1≤W[i],S[i]≤105
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.
The first line contains the number of test cases, T = 1
The first test case
Given
Approach