General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
109596686 Contestant:
Tsovak
1496B - 24 GNU C++17 Accepted 93 ms 4348 KB 2021-03-10 16:11:18 2021-03-10 17:21:51
 
 
→ Source
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
//#include <unordered_set>
#include <map>
//#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double

#define mpr make_pair
#define ff first
#define ss second

ll gcd(ll a, ll b)
{
	if (a == 0)
		return b;
	if (b == 0)
		return a;
	if (a == b)
		return a;
	if (a > b)
		return gcd(a - b, b);
	return gcd(a, b - a);
}

bool prime(ll a)
{
	for (ll i = 2; i * i <= a; i++)
		if (a % i == 0)
			return false;
	return true;
}

map<int, int> mp;

set<int> st;

vector<int> v;

void solve()
{
	int i, j;
	int k, n, a;
	st.clear();
	v.clear();
	mp.clear();
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> a;
		st.insert(a);
	}
	int ind, maxx, mexx;
	for (auto i : st) {
		v.push_back(i);
	}
	i = 0;
	for (j = 0; j < k; j++) {
		if (v[0] != 0)
			mexx = 0;
		else {
			mexx = -1;
			for (i; i < n - 1; i++) {
				if (v[i] + 1 < v[i + 1]) {
					mexx = v[i] + 1;
					break;
				}
			}
			if (mexx == -1) {
				cout << st.size() + k << endl;
				return;
			}
		}
		maxx = v[v.size() - 1];
		int d = (maxx + mexx + 1) / 2;
	//	cout << maxx << ' ' << mexx << ' ' << d << endl;
		if (mp[d] == 1) {
			break;
		}
		st.insert(d);
		mp[d] = 1;
		auto it = upper_bound(v.begin(), v.end(), d - 1);
		v.insert(it, d);
	}
	cout << st.size() << endl;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll t = 1, tt;
	cin >> t;
	for (tt = 0; tt < t; tt++) {
		solve();
	}
	return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details