-
Notifications
You must be signed in to change notification settings - Fork 0
/
1539C.cpp
41 lines (32 loc) · 820 Bytes
/
1539C.cpp
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
#include<bits/stdc++.h>
#define ll long long int
#define show(x) cout << #x << " : " << x << endl
using namespace std;
int main()
{
ll n,k,x , ans = 0;
cin >> n >> k >> x;
vector<ll> v,vs;
for (int i=0 ; i<n ; i++){
ll a;
cin >> a ;
v.push_back(a);
}
sort(v.begin(),v.end());
for (int i=1 ; i<n; i++){
if ((v[i]-v[i-1]-1)/x > 0)vs.push_back((v[i]-v[i-1]-1)/x);
}
if (!vs.empty())sort(vs.begin(),vs.end());
ans = (ll)vs.size()+1;
// show(ans);
// for (int i=0 ; i<vs.size() ; i++){
// cout << vs[i] << " ";
// }
// cout << endl;
for (int i=0 ; i<vs.size() ; i++){
k-=vs[i];
if (k>=0)ans--;
}
cout << ans << endl;
return 0;
}