AKVOD05 – Ross generates Data Solution

0
3
SPOJ Solution

AKVOD05 Statement

Ross wants to complete the data set for his next research work. He has to generate a set of “N” non negative integers. He already knows the first “K” values out of them. He knows how to generate the remaining values. Any of the remaining values will be the minimum non negative integer that does not exist in the previous “K” values.

For example, let the value of “N” is 7 and the value of “K” be 4 and the first “K” values be 0 4 3 2 then the next 3 values will be 1 0 4.

You just have to generate the “N”th value for his work.

Input

The first line will contain “T”, the no. of test cases. Then “T” test cases follows. For each test case, the first line will contain two integers “N” and “K”. The next line will contain “K” integers denoting the “K” values that he already knows.

Output

For each test case, output a single integer value that denotes the “N”th integer in his data set.

AKVOD05 Solution

May you like to see:

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.