#CT0000149. Số còn thiếu thứ k (K-th Missing Number)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Số còn thiếu thứ k (K-th Missing Number)
K-th Missing Number
Version: Phuoc Hung OJ Extended
Problem Statement

A storage system uses positive integer codes . Exactly codes have been assigned, listed as a strictly increasing sequence .
A positive integer not present in this list is a missing number. Listing all missing numbers in increasing order yields an infinite sequence. For example, if the assigned codes are , the first missing numbers are
There are independent queries. Given a positive integer in each query, find the -th missing number in this increasing sequence.
Input
The first line contains two positive integers and .
The second line contains exactly strictly increasing positive integers .
Each of the next lines contains a positive integer , specifying the rank of the missing number to find.
Output
Print exactly lines in query order. Each line contains the positive integer that is the -th missing number for the corresponding query.
Subtasks
- Subtask 1 (30 points): ; ; in each query.
- Subtask 2 (30 points): ; ; in each query.
- Subtask 3 (40 points): ; ; in each query.
Examples
Example 1
Input
3 5
2 3 7
1
2
3
4
5
Output
1
4
5
6
8
Explanation
Assigned codes are . Removing them from the positive integers leaves the first five missing values . The queries ask for ranks , so these five values are printed in order.
Example 2
Input
3 3
1 2 3
1
2
10
Output
4
5
13
Explanation
The assigned codes are , so missing numbers begin . The first is , the second is , and the tenth is .
Example 3
Input
4 4
1 3 4 10
1
3
5
8
Output
2
6
8
12
Explanation
Assigned codes are . The first missing numbers are . Therefore ranks produce .
Liên quan
Trong các cuộc thi sau: