-
Notifications
You must be signed in to change notification settings - Fork 0
/
C1539.cpp
34 lines (34 loc) · 789 Bytes
/
C1539.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
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
int main(){
ll n,k,count,x,need;
cin>>n>>k>>x;
vector<ll> v(n, 0),needs;
for(ll i=0; i<n; i++){
cin>>v[i];
}
sort(v.begin(),v.end());
for(ll i=1;i<n;i++){
if((v[i] - v[i - 1]) <= x)
continue;
need = (v[i] - v[i - 1]);
need-=(need % x == 0 ? x: 0);
need/=x;
needs.push_back(need);
}
sort(needs.begin(), needs.end());
int i;
for(i=0;i<needs.size();i++){
if(k < needs[i])
break;
k-=needs[i];
}
cout<<(needs.size() - i + 1)<<endl;
return 0;
}