아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

kex

면접 대비

시간 제한2초메모리 제한1024 MB

요약
서로 다른 음이 아닌 정수 n개로 이루어진 집합과 q개의 k가 주어질 때, 집합에 없는 음이 아닌 정수 중 k번째로 작은 값을 구한다.
난이도

보통10점 중 5점

유형
이분 탐색, 정렬, 누적 합, 수학
정답자
아직 제출이 없습니다

문제

Consider the set of non-negative integers AA. The minimum non-negative integer that does not occur in this set is considered, for example, in game theory, and is denoted as mex(A)\mathrm{mex}(A). For example, mex(0,1,2,4,5,9)=3\mathrm{mex}(\\{0, 1, 2, 4, 5, 9\\})=3.

Ann has decided to generalize the concept of mex. Consider a positive integer kk and a set of non-negative integer AA. Denote as kex(A,k)\mathrm{kex}(A,k) a non-negative integer that is kk-th in ascending order among all integers that are not in AA. For example, kex(0,1,2,4,5,9,2)=6\mathrm{kex}(\\{0, 1, 2, 4, 5, 9\\}, 2)=6.

You must find kex(A,k_i)\mathrm{kex}(A, k\_i) for the given set of integers AA and qq values of k_ik\_i.

입력

The first line of input contains two integers nn and qq (1≤n,q≤1051 \leq n, q \leq 10^5) --- number of elements in AA and number of kex\mathrm{kex} numbers, that you have to find.

In second line of input contains nn different not negative integers, each of which is at most 10910^9, --- elements of AA.

In third line of input contains qq integers k_ik\_i (1≤k_i≤1091\leq k\_i \leq 10^9).

출력

Print values: kex(A,k_1),kex(A,k_2),…,kex(A,k_q)\mathrm{kex}(A, k\_1), \mathrm{kex}(A, k\_2),\ldots, \mathrm{kex}(A,k\_q).

예제1

  1. 예제 1

    입력
    4 10
    1 2 6 7
    1 2 3 4 5 6 7 8 10 11
    
    예상 출력
    0 3 4 5 8 9 10 11 13 14