AtCoder Beginner Contest 205
D
Kth Excluded
AtCoder
⌀ 713
原题
← CE →
翻译中…

Problem Statement

翻译中…

You are given a sequence of $N$ positive integers: $A = (A_1, A_2, \dots, A_N)$, and $Q$ queries.

翻译中…

In the $i$-th query $(1 \leq i \leq Q)$, given a positive integer $K_i$, find the $K_i$-th smallest integer among the positive integers that differ from all of $A_1, A_2, \dots, A_N$.

翻译中…

Constraints

翻译中…
  • $1 \leq N, Q \leq 10^5$
  • $1 \leq A_1 < A_2 < \dots < A_N \leq 10^{18}$
  • $1 \leq K_i \leq 10^{18}$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N Q
A_1 A_2 \ldots A_N
K_1
K_2
\vdots
K_Q

翻译中…

Output

翻译中…

Print $Q$ lines. The $i$-th line should contain the response to the $i$-th query.

翻译中…

样例

Input #1
4 3
3 5 6 7
2
5
3
Output #1
2
9
4
The positive integers that differ from all of $A_1, A_2, \dots, A_N$ are $1, 2, 4, 8, 9, 10, 11, \dots$ in ascending order. The second, fifth, and third smallest of them are $2$, $9$, and $4$, respectively.
Input #2
5 2
1 2 3 4 5
1
10
Output #2
6
15
题目信息
题号
abc205_d
时间限制
3 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。