cswork / OA打开练习工作台

MetaOA #18

Kth Missing Positive Number (for E4 :)

估计简单可在线判题

考点(AI 标注)二分查找

Given a strictly increasing array a of positive integers and a positive integer k, output the k-th positive integer that does not appear in the array.

输入格式

This site's standard input scale: the first line contains n k (1..100000, 1..10⁹), and the second line contains n strictly increasing positive integers (1..10⁹).

输出格式

Output the answer as described; separate multiple results with spaces in order, and output an empty line for an empty array.

样例 1

输入:

5 5
2 3 4 7 11

输出:

9

样例 2

输入:

4 2
1 2 3 4

输出:

6

样例 3

输入:

1 1
3

输出:

1

样例说明

Example 1: the missing numbers are 1, 5, 6, 8, 9 in order, so the 5th missing positive integer is 9.