Question: C Programing Language Problem Title : Minimum You are given an array of N integers, A 1 , A 2 , . . . ,

C Programing Language

Problem Title : Minimum

You are given an array of N integers, A1, A2, . . . , AN , and M integers, X1, X2, . . . , XM. For each Xi where i is an integer from 1 to M, you are asked to find the minimum index Y , such that the minimum value of (A1, A2, . . . , AY ) <= Xi .

Format Input

The first line consist of two integers, N and M. The second line consist of N integers, A1, A2, . . . , AN . The third line consist of M integers, X1, X2, . . . , XM.

Format Output

Output M lines, each consist of an integer which is the minimum index Y , such that the minimum value of (A1, A2, . . . , AY ) <= Xi . If no such Y is found, output -1.

Constraints

1 N, M 105

1 Ai , Xi 109

Sample Input 1 (standard input)

7 4

3 3 3 3 2 2 2

1 3 2 8

Sample Output 1 (standard output)

-1

1

5

1

NOTE :

Input And Output Must Be The Same

Don't use library Stdlib.h

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!