C. Stable Groups

time limit per test

1 second

memory limit per test

256 megabytes

There are n students numerated from 1 to n. The level of the i-th student is ai. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements differ by more than x.

For example, if x=4, then the group with levels [1,10,8,4,4] is stable (because 4−1≤x, 4−4≤x, 8−4≤x, 10−8≤x), while the group with levels [2,10,10,7] is not stable (7−2=5>x).

Apart from the n given students, teachers can invite at most k additional students with arbitrary levels (at teachers' choice). Find the minimum number of stable groups teachers can form from all students (including the newly invited).

For example, if there are two students with levels 1 and 5; x=2; and k≥1, then you can invite a new student with level 3 and put all the students in one stable group.

Input

The first line contains three integers n, k, x (1≤n≤200000, 0≤k≤1018, 1≤x≤1018) --- the initial number of students, the number of students you can additionally invite, and the maximum allowed level difference.

The second line contains n integers a1,a2,...,an (1≤ai≤1018) --- the students levels.

Output

In the only line print a single integer: the minimum number of stable groups you can split the students into.

Examples

Input

Copy

复制代码
8 2 3
1 1 5 8 12 13 20 22

Output

Copy

复制代码
2

Input

Copy

复制代码
13 0 37
20 20 80 70 70 70 420 5 1 5 1 60 90

Output

Copy

复制代码
3

Note

In the first example you can invite two students with levels 2 and 11. Then you can split the students into two stable groups:

  1. 1,1,2,5,8,11,12,13\],

In the second example you are not allowed to invite new students, so you need 3 groups:

  1. 1,1,5,5,20,20

  2. 60,70,70,70,80,90

  3. 420

解题说明:此题是一道模拟题,采用贪心算法,首先对数列进行排序,然后针对差值再进行排序。将填充的k个值与不满足条件的差值进行判断,首先填充到最开始不满足条件的差值位置中。否则只能将数列拆分。

cpp 复制代码
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main() 
{
	long long a[200001], b[200001], cnt, n, x, k;
	cin >> n >> k >> x;
	for (int i = 1; i <= n; i++) 
	{
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for (int i = 2; i <= n; i++)
	{
		b[i - 1] = a[i] - a[i - 1];
	}
	sort(b + 1, b + n);
	for (int i = 1; i < n; i++)
	{
		if (b[i] > x)
		{
			if (k >= (b[i] - 1) / x)
			{
				k -= (b[i] - 1) / x;
			}
			else
			{
				cnt++;
			}
		}
	}
	cout << ++cnt;
	return 0;
}
相关推荐
-许平安-1 小时前
MCP项目笔记四(Transport)
开发语言·c++·笔记·ai·mcp
SuperEugene1 小时前
Vue3 + Element Plus 表单校验实战:规则复用、自定义校验、提示语统一,告别混乱避坑|表单与表格规范篇
开发语言·前端·javascript·vue.js·前端框架
2401_894241921 小时前
基于C++的数据库连接池
开发语言·c++·算法
阿贵---1 小时前
C++中的适配器模式
开发语言·c++·算法
C羊驼1 小时前
C语言学习笔记(十二):动态内存管理
c语言·开发语言·经验分享·笔记·青少年编程
SuperEugene2 小时前
Vue3 + Element Plus 表格查询规范:条件管理、分页联动 + 避坑,标准化写法|表单与表格规范篇
开发语言·前端·javascript·vue.js·前端框架
小邓睡不饱耶2 小时前
东方财富网股票数据爬取实战:从接口分析到数据存储
开发语言·爬虫·python·网络爬虫
dapeng28702 小时前
C++与Docker集成开发
开发语言·c++·算法
2501_945423542 小时前
C++中的策略模式实战
开发语言·c++·算法