


Ninja is in the mood for a walk over the city, but being a ninja he prefers jumping over building roofs instead of walking through the streets.
The height of the buildings in his city can be represented through an array ‘HEIGHTS’ where ‘HEIGHT[i]’ is the height of the ith building. Ninja starts his journey from the 1st building and in one step can only travel to the roof of the next building.
While traveling from the ‘i’th to (i+1)th building:
1. If the ith building has a height greater than or equal to the next i.e (i+1)th building then he simply jumps to the next building.
2. Otherwise he uses either {‘HEIGHTS[i+1] -‘HEIGHTS[i]} bricks or just 1 ladder to climb up to the next building.
Having a limited number of bricks say ‘BRICKS’ and a limited number of ladders say ‘LADDERS’ in his Ninja pocket, he wants to know which is the farthest building he can travel up to if he uses the bricks and ladders optimally.
As Ninja is weak in mathematics so he asks for your help, can you help Ninja to find the maximum index of the building he can reach up to(1 based indexing)?
Input Format:
The first line of input contains an integer ‘T’ denoting the number of test cases. Then each test case follows.
The first line of each test case contains three integers ‘N’, ‘BRICKS’ and ‘LADDERS’ denoting the number of buildings, number of bricks, and number of ladders respectively.
The second line contains ‘N’ space-separated distinct integers where the ith integer denotes the height of the ith building.
Output format:
For each test case, print a single line containing a single integer, denoting the maximum index of the building chef can travel up to using the bricks and ladders optimally.
The output of every test case will be printed in a separate line.
Note :
You don’t have to print anything, it has already been taken care of. Just implement the given function.
Constraints
1 <= T <=10
2 <= N <= 10 ^ 5
1 <= HEIGHTS[i] <= 10 ^ 6
0 <= ‘BRICKS’<= 10 ^ 4
0 <=’LADDERS’ < N
Where ‘T’ denotes the number of test cases, ‘N’ denotes the size of ‘HEIGHTS’ and ‘HEIGHT[i]’ denotes the height of the ith building, ‘BRICKS’ denotes the number of bricks and ‘LADDERS’ denote the number of ladders.
Time limit: 1 second
1
5
2 5 4 3 8
4 1
5
For test case 1:

Ninja is currently standing on the 1st building.

As building 2 has a height greater than building 1, he can use (5-2) = 3 bricks to climb up to building 2. He is now left with 1 brick and 1 ladder.

The 3rd building has a height less than 2nd, so he can simply jump to the 3rd building.

The 4th building has a height less than 3rd, so he jumps again.

The 5th building is taller than the 4th one, so Ninja uses 1 ladder to go to the top building. Hence he can travel up to the 5th building.
1
6
2 7 1 5 6 2
3 1
3
In the first step, Ninja can use 1 ladder to go to the 2nd building.
Then the 3rd building has a height smaller than the 2nd building so he jumps to the 3rd building.
Now he does not have sufficient ladders or bricks to go to the 4th building, hence the answer is 3.
Check whether you can reach the last building or not.
Complete Algorithm :
O(N ^ 2 * log(N)), where N is the size of ‘HEIGHTS’.
For each building from 1 to ‘N’ we check if it is reachable or not. And for each building we do the sum of the ‘M’ - ‘ladder’ smallest increments till now, which in the worst case can have a size ’N’. Hence the time complexity is O(N ^ 2 * log(N)).
O(N), where N is the size of ‘HEIGHTS’.
If the building's heights are in increasing order, then we can encounter at max ‘N’ increments. Therefore at any index, we add at max ‘N’ values to the multiset. Each value takes O(1) space in the multiset which makes the space complexity O(‘N’).