#include<bits/stdc++.h>
#define int long long
#define lb(x) x&-x
using namespace std;
int n,d,k;
struct node{
int x,h;
}a[1222222];
bool cmp(node x,node y)
{
return x.x<y.x;
}
int ans;
int find(int x)
{
int l=1,r=n,mid=0,we=0;
while(l<=r)
{
mid=(l+r)/2;
if(x>=a[mid].x)
{
l=mid+1;
we=mid;
}
else
{
r=mid-1;
}
}
return we;
}
int t[1222222];
void update(int x,int y)
{
for(;x<=1000000;x+=lb(x))
{
t[x]+=y;
}
}
int sum(int x)
{
int s=0;
for(;x;x-=lb(x))
{
s+=t[x];
}
return s;
}
signed main()
{
cin>>n>>d>>k;
for(int i=1;i<=n;i++)
{
cin>>a[i].x>>a[i].h;
update(i,a[i].h-a[i-1].h);
}
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++)
{
// if(a[i].h>0)
if(sum(i)>0)
{
int cs=ceil(sum(i)*1.0/k);
ans+=cs;
int r=find(a[i].x+d+d);
// cout<<a[i].x+d+d<<" "<<r<<endl;
update(i,-(k*cs));
update(r+1,k*cs);
}
}
cout<<ans;
}
贪心+树状数组(差分)