Question: C Programming Language ( Code With C Programming Language) Problem Title : Minimum You are given an array of N integers, A 1 , A
C Programming Language ( Code With C Programming 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 100000
- 1 Ai, Xi 1000000000
Sample Input & Output (Standard Input & Output)
7 4 3 3 3 3 2 2 2 1 3 2 8 -1 1 5 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
