Dreamoon is a big fan of the Codeforces contests.
One day, he claimed that he will collect all the places from 11 to 5454 after two more rated contests. It's amazing!
Based on this, you come up with the following problem:
There is a person who participated in nn Codeforces rounds. His place in the first round is a1a1, his place in the second round is a2a2, ..., his place in the nn-th round is anan.
You are given a positive non-zero integer xx.
Please, find the largest vv such that this person can collect all the places from 11 to vv after xx more rated contests.
In other words, you need to find the largest vv, such that it is possible, that after xx more rated contests, for each 1≤i≤v1≤i≤v, there will exist a contest where this person took the ii-th place.
For example, if n=6n=6, x=2x=2 and a=[3,1,1,5,7,10]a=[3,1,1,5,7,10] then answer is v=5v=5, because if on the next two contest he will take places 22 and 44, then he will collect all places from 11 to 55, so it is possible to get v=5v=5.
The first line contains an integer tt (1≤t≤51≤t≤5) denoting the number of test cases in the input.
Each test case contains two lines. The first line contains two integers n,xn,x (1≤n,x≤1001≤n,x≤100). The second line contains nn positive non-zero integers a1,a2,…,ana1,a2,…,an (1≤ai≤1001≤ai≤100).
For each test case print one line containing the largest vv, such that it is possible that after xx other contests, for each 1≤i≤v1≤i≤v, there will exist a contest where this person took the ii-th place.
5 6 2 3 1 1 5 7 10 1 100 100 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 57 80 60 40 20
5 101 2 2 60
The first test case is described in the statement.
In the second test case, the person has one hundred future contests, so he can take place 1,2,…,991,2,…,99 and place 101101 on them in some order, to collect places 1,2,…,1011,2,…,101
Put translation
Qingming ancestors had to make up the title today]
This title means ... I think quite a while did not understand ...
In fact, it is such that each set of test data is given and the number n can add a number of x, and n digital to want to know where the maximum number of consecutive continuously, starting at 1 [which will make up less, Up to complement x times
Know the meaning of this title, this title became cute, you can put the number n is stored in an array, and then traverse the time, if a vacancy to fill and then X--; when X == 0 it [ after a number of run] come out, and then traverse the time to find the last one in a row and not [to find friends ^^ 0
. 1 #include <bits / STDC ++ H.>
2 #define LL longlongs
. 3 the using namespace STD;
. 4 int A [ 1002 ]; // open space otherwise distressed debug array can not die
. 5 int main () {
. 6 int T;
. 7 CIN >> T;
. 8 the while (T-- ) {
. 9 int n-, X;
10 CIN >> >> n- X;
. 11 // set {0 ..... painful important lessons
12 is Memset (A, 0 , the sizeof (A)); // array set to zero
13 is for ( int I = 0 ; I <n-; I ++ ) {
14 int m;
15 CIN >> m;
16 A [m] = . 1 ; // set this position is occurred
. 17 }
18 is int J = . 1 ;
. 19 the while ( . 1 ) {
20 is iF (a [J] == 0 ) { // if this location does not appear, but I have the time to fill the remaining x
21 is x--; // number of times x is one less
22 is a [ J] = 1 ; // this location mended
23 }
24 IF (x <= 0 ) BREAK ; // number of times x is not the out of the loop;
25 J ++ ;
26 is }
27 / * for (int I = 0; I <100; I ++) COUT << A [I] < < ''; // used to debug the own
28 COUT << "\ n-';
29 * /
30 int in Flag = 0 ;
31 is for ( int I = . 1 ; I <= 1002 ; I ++) { // iterate again see which place not from
32 iF (a [I] == 0 ) { // when this position is 0 when the instructions to which ended
33 = I- In Flag 1 ; // Save the last one because the former is a position 0 of
34 is BREAK ;
35 }
36 }
37 [ COUT In Flag << << ' \ n- ' ; // output
38 is }
39 return 0 ;
40 }