#include<iostream>
#include<math.h>
#include <vector>
#include <string>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <numeric> //accmulate
#include <fstream>
#include <iomanip> //setprecision() setw()
using namespace std;
//#define cin infile
//C++文件输入
ifstream infile("in.txt", ifstream::in);
//#define test01
//#define test02
#define test03
// 第一题
#if 0
int main()
{
// test
char str[] = "hello world!";
char str1[12];
//str1 = "hello"; //bug
char *p = "hello";
char*q;
q = "hello";
//数组去重
vector<int> array = {1,2,2,3,4,4,4,5,6,7,7,9};
int s = 0, t = 1;
for (; t < array.size();6)
{
if (array[s]==array[t])
{
t++;
}
else
{
array[++s] = array[t++];
}
}
copy(array.begin(), array.end(), ostream_iterator<int>(cout, " "));
int n, k;
cin >> n >> k;
vector<int> vec;
int temp = 0;
for (int i = 0; i < n; i++)
{
cin >> temp;
vec.push_back(temp);
}
sort(vec.begin(), vec.end());
int len = unique(vec.begin(), vec.end()) - vec.begin(); //unique去重原理
int ret = 0;
int low = 0, high = 1;
for (int i = 0; i < len;i++)
{
while (high<len&&vec[high]-vec[low]<k)
{
high++;
}
if (high==n)
{
break;
}
if (vec[high]-vec[low]==k)
{
ret++;
}
}
cout << ret << endl;
return 0;
}
//int main()
//{
// int n, k;
// cin >> n >> k;
//
// set<int> vec; //unodered_map
// int temp = 0;
// for (int i = 0; i < n;i++)
// {
// cin >> temp;
// vec.insert(temp);
// }
//
// int ret = 0;
//
// for (auto it = vec.begin(); it != vec.end();it++)
// {
// int t = *it + k;
// auto end = vec.end();
// end--;
// if (t>*end)
// {
// break;
// }
// //int t1 = *it - k;``
// if (vec.find(t)!=vec.end()/*||vec.find(t1)!=vec.end()*/)
// {
// ret++;
// }
// }
//
// cout << ret << endl;
//
// return 0;
//}
#endif
// 第二题
#if 0
int dfs(string&s, string &m, string ans, int ret)
{
if (s == ans)
{
return ret;
}
if (s.size() > ans.size())
{
return 0xFFFF;
}
else
{
return min(dfs(s + s, s, ans, ret + 1), dfs(s + m, m, ans, ret + 1));
}
}
int main()
{
//C++文件输入
ifstream infile("in.txt", ifstream::in);
int n = 6; //字符串长度
//cin >> n;
string s = "a";
string m = s;
string ans(n, 'a');
int ret = 0;
ret = dfs(s, m, ans, ret);
cout << ret << endl;
return 0;
}
//bfs
//typedef pair<int, int> pii;
int main()
{
int n = 6; //字符串长度
//cin >> n;
string s = "a";
string m = s;
string ans(n, 'a'); //初始化
pair<string, string> pa(s,m);
map<pair<string, string>, int> mp;// 实际就是求bfs的层数
queue<pair<string, string>> que;
que.push(pa);
mp[pa] = 0;
while (!que.empty())
{
pair<string, string> temp;
temp=que.front();
que.pop();
if (temp.first==ans)
{
cout << mp[temp] << endl;
break; //exit(0);
}
pair<string, string> t;
t = temp;
t.second = t.first; t.second = t.second + t.second; //方式一
if (!mp.count(t))
{
que.push(t);
mp[t] = mp[temp] + 1;
}
t = temp;
t.first = t.first + t.second;
if (!mp.count(t))
{
que.push(t);
mp[t] = mp[temp] + 1;
}
}
return 0;
}
#endif
//第三题
#if 0
//int main()
//{
// int n, m;
// cin >> n >> m;
// vector<int> a;
// vector<int> b;
// int temp = 0;
// for (int i = 0; i < n;i++)
// {
// cin >> temp;
// a.push_back(temp);
// }
// for (int i = 0; i < m;i++)
// {
// cin >> temp;
// b.push_back(temp);
// }
//
// double ave1 = double(accumulate(a.begin(), a.end(), 0))/n;
// double ave2 = double(accumulate(b.begin(), b.end(), 0)) / m;
//
// int cnt1 = 0;
// for (int i = 0; i < n;i++)
// {
// if ((a[i]>=ave1&&a[i]<=ave2)||(a[i]<=ave1&&a[i]>=ave2))
// {
// cnt1++;
// }
// }
//
// int cnt2 = 0;
// for (int i = 0; i < m; i++)
// {
// if ((b[i]>=ave1&&b[i] <= ave2) || (b[i]<=ave1&&b[i]>=ave2))
// {
// cnt2++;
// }
// }
// cout << cnt1 + cnt2 << endl;
//
// return 0;
//}
#endif
//第五题
#if 1
int main()
{
int n, k, h,temp;
cin >> n >> k >> h; //n表示跳板的个数,k为最多跳k次,h最大的高度差
vector<int> vec;
for (int i = 0; i < n;i++)
{
cin >> temp;
vec.push_back(temp);
}
sort(vec.begin(), vec.end());
queue<int> que; //里面装每一层的所能达到的高度
int j = 0;
while (vec[j]<h)
{
int h_new = 0 + (vec[j] - 0) * 2;
que.push(h_new);
j++;
}
int iter = 0;
while (!que.empty())
{
iter++;
int size = que.size();
for (int i = 0; i < size;i++)
{
int t = que.front();
que.pop();
//每次都需要找到当前高度差<abs(h)内的跳板,比较麻烦
}
if (iter==k)
{
}
}
}
// 牛客网:https://www.nowcoder.com/discuss/70299
#include <iostream>
using namespace std;
const int N = 1e5 + 1000;
typedef pair<int, int> pii;
bool vis[N];
int a[N];
int main()
{
int n, k, h;
scanf("%d%d%d", &n, &k, &h);
for (int i = 0; i < n; ++i)
{
int t;
scanf("%d", &t);
a[t] = 1;
}
queue<pii> q;
q.push({ 0, 0 });
int ans = 0;
while (!q.empty())
{
pii p = q.front(); q.pop();
if (p.second > k) break;
ans = max(ans, p.first);
for (int i = 1; i <= h; ++i)
{
if (a[p.first + i] && !vis[p.first + 2 * i])
{
vis[p.first + 2 * i] = true;
q.push(make_pair(p.first + 2 * i, p.second + 1));
}
if (p.first - 2 * i > 0 && a[p.first - i] && !vis[p.first - 2 * i])
{
vis[p.first - 2 * i] = true;
q.push(make_pair(p.first - 2 * i, p.second + 1));
}
}
}
printf("%d
", ans);
return 0;
}
#endif