fork(3) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define FAST1 ios_base::sync_with_stdio(false);
  5. #define FAST2 cin.tie(NULL);
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define ll long long
  9. #define FAST1 ios_base::sync_with_stdio(false);
  10. #define FAST2 cin.tie(NULL);
  11.  
  12.  
  13. void solve(){
  14. ll n,k,s;
  15. cin>>n>>k>>s;
  16. ll arr[n];
  17. for(ll i=0;i<n;i++)
  18. cin>>arr[i];
  19. sort(arr,arr+n);
  20. vector<ll> v;
  21. for(ll i=1;i<n;i++){
  22. if(arr[i]-arr[i-1]>s){
  23. v.push_back((arr[i]-arr[i-1]-1)/s);
  24. }
  25. }
  26. sort(v.begin(),v.end());
  27. reverse(v.begin(),v.end());
  28. while(v.size()){
  29. if(v[v.size()-1]<=k){
  30. k-=v[v.size()-1];
  31. v.pop_back();
  32. }
  33. else
  34. break;
  35. }
  36. cout<<v.size()+1<<endl;
  37. }
  38.  
  39. int main(){
  40. FAST1;
  41. FAST2;
  42. ll t=1;
  43. //cin>>t;
  44. while(t--){
  45. solve();
  46. }
  47. }
  48.  
Success #stdin #stdout 0.01s 5644KB
stdin
8 2 3
1 1 5 8 12 13 20 22
stdout
2