Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast", "unroll-loops")
- #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- #include <string>
- #include <map>
- #include <unordered_map>
- #include <set>
- #include <unordered_set>
- #include <bitset>
- #include <sstream>
- #include <deque>
- #include <queue>
- #include <random>
- #include <cassert>
- #include <stack>
- #include <fstream>
- using namespace std;
- #define ll long long
- #define ld long double
- #define inf 1000000007
- #define all(a) a.begin(), a.end()
- #define files(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
- template<class T> inline void sort(T &a) { sort(all(a)); }
- template<class T> inline T sorted(T a) { sort(a); return a; }
- template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }
- void solve() {
- int n, x;
- cin >> n >> x;
- vector<int> a;
- for (int k = 0; k < n; ++k) {
- int aa;
- cin >> aa;
- a.push_back(aa);
- }
- sort(all(a));
- int t = 0, tt = 0, xx = x;
- for (int i = 1; i <= n + xx; ++i) {
- for (int j = 0; j < n; ++j) {
- if (i != a[j] && j == n - 1) {
- //cout << "notfound " << i << ' ' << x << '\n';
- x--;
- a.push_back(i);
- tt++;
- }
- if (i == a[j]) {
- //cout << "found " << i << '\n';
- break;
- }
- }
- //cout << tt << '\n';
- if (x == 0) {
- break;
- }
- }
- sort(all(a));
- for (int l = 0; l < n+tt; ++l) {
- //cout << a[l] << ' ';
- if (a[l + 1] - a[l] > 1 || l == n+tt-1) {
- cout << a[l] << '\n';
- break;
- }
- }
- }
- signed main() {
- FAST;
- // files("goat4.in", "goat4.out");
- int f = 1;
- cin >> f;
- while (f--) {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement