Binary vs Linear search

3

6 votes
Very-Easy
Problem

You are a given an array of N elements.
Now you have to answer Q queries.
Each Query contains an integer K.
For each query you have to print number of elements present in array which are less than or equal to K.

Input :
first line contains an integer 'N' (number of elements in array).
On next line there will be N integers (array elements).
on next line there is an integer Q (number of Queries)
Next Q lines contains an integer K.

output :
for each K print the required output

constraint :
1<=N<=5000
1<=Q<=1000000
1<=K=<1000000000
1<=a[i]<=1000000000

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

?