看劈叉了都,看下面思路还是很好懂的
Accode:
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+10;
int n,k,a[N],cnt;
bool flag;
void solve() {
cin>>n>>k;
for(int i=1; i<=n; i++) cin>>a[i];
for(int i=1;i<n;i++){
int x=abs(a[i+1]-a[i]);
if(x>=k)flag=true;
if(x>k)cnt+=(x-1)/k;
}
if(flag)cout<<cnt<<"\n";
else cout<<1<<"\n";
}
signed main() {
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int tt=1;
//cin>>tt;
while(tt--) {
solve();
}
return 0;
}
over~