Baahubali And Movies

3.3

25 votes
Problem

Baahubali and Kattappa are very good friends. Baahubali wants to give Kattappa a movie as a birthday gift. He gets a list of movies that are available.

Each movie is rated on a scale of 1-1000 and a cost between 1 to 100. He would like to gift a movie whose rating is atleast K. Help Baahubali find such movie whose cost is minimum.

Input:

First Line of Input contains T, number of test cases.

First Line of each test case Contains an Integer N and K ,denoting the number of movies in his list and minimum rating needed.

Second Line of each test case contains N integers denoting rating of each movie.

Third Line of each test case contains N integers denoting cost of each movie.

Output:

Print the position of the movie (0 indexed) in the list in a single line for each test case.

If there are multiple such movies, print the one with least position. It is guaranteed that such movie exists in the list.

Constraints:

1 <= T <= 100

1 <= N <= 10000

10 <= K <= 1000

Sample Input:

3

6 3

2 6 1 3 4 3

8 9 7 10 19 18

4 6

9 3 2 4

7 6 2 1

8 4

1 2 5 8 9 4 3 2

4 3 2 12 23 45 67 4

Sample Output:

1

0

2

Explanation:

The Input contains 3 Test Cases.

First Case: 1st movie is the least expensive movie in the list to have a rating more than K=3.

Second Case: Only 0th movie's rating is more than a required rating of K=6.

Third Case: 2nd Movie is the first movie in the list to have a rating more than K=4 with least cost.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?