Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6381
@blackshadows 6329
@mb1973 5388
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3357
@KshamaGupta 3318
Complete Leaderboard
Count the elements
Easy Accuracy: 42.67% Submissions: 18309 Points: 2

Given two arrays A and B. Given Q queries each having a positive integer i denoting an index of the array A. For each query, your task is to find all the elements less than or equal to Ai in the array B.

Input:
The first line contains a single integer T, the number of test cases. The first line of each test case consists of a integer N. The second and third line of each test case consists of N spaced integers representing array A and array B respectively. The third line contains a positive integer Q, denoting the number of queries. Next Q lines contains queries.

Output: 
For each testcase, print the required answer.

Constraints:
1 <= T <= 100
1 <= N <= 107
1 <= Ai, Bi <= 107
1 <= Q <= 103

Example:
Input:

1
6
1 2 3 4 7 9
0 1 2 1 1 4
2
5

Output:

6
6

Explanation:
Testcase 1:
For 1st query, the given index is 5, A[5] is 9 and in B all the elements are smaller than 9.
For 2nd query, the given index is 4, A[4] is 7 and in B all the elements are smaller than 7. 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Count the elements

Output Window