kex
InterviewTime limit2sMemory limit1024 MB
Given a set A and several values k, find for each k the k-th smallest non-negative integer that is not in A.
- Level
Medium4 of 10
- Topics
- Binary search, Sorting, Array
- Solved
- No attempts yet
Statement
Consider the set of non-negative integers . The minimum non-negative integer that does not occur in this set is denoted . For example, .
Ann generalizes the concept of mex. For a positive integer and a set of non-negative integers , is the -th smallest integer that is not in . For example, .
For the given set and values , find for each .
Input
The first line contains two integers and (), the number of elements in and the number of kex values to find.
The second line contains distinct non-negative integers, each at most . These are the elements of .
The third line contains integers ().
Output
Print .