-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdreamoonandrankingcollection.cpp
More file actions
65 lines (62 loc) · 1.18 KB
/
Copy pathdreamoonandrankingcollection.cpp
File metadata and controls
65 lines (62 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<bits/stdc++.h>
using namespace std;
// https://codeforces.com/contest/1330/problem/A
#define ll long long
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define MOD 1000000007
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--)
{
int s,x;
cin>>s>>x;
set<int> a;
for(int i=0;i<s;i++)
{
int t;
cin>>t;
a.insert(t);
}
int n=a.size();
int find=1,ans=1;
auto it=a.begin();
while(it!=a.end() && x>0)
{
if(*it==find)
{
ans=find;
find++;
it++;
}
else if(*it>find)
{
x--;
ans=find;
find++;
}
else
{
it++;
}
}
while(x>0)
{
ans++;
x--;
}
while(it!=a.end() && *it==find)
{
ans=find;
find++;
it++;
}
cout<<ans<<endl;
}
return 0;
}