Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
#define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


const int MAX_N = 1<<19;
int dat[2 * MAX_N -1];
int n;

struct SegmentTree{
    SegmentTree(int n_){
        n=1;
        while(n<n_) n*= 2;
        for(int i=0;i<2*n-1;i++){
            dat[i]=0;
        }
    }
    int query(int k){
        k += n-1;
        int count=dat[k];
        while(k>0){
            k=(k-1)/2;
            count+=dat[k];
        }
        return count;
    }
    void update(int a,int b,int k,int p,int l,int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            dat[k]+=p;
        }
        else{
            update(a,b,k*2+1,p,l,(l+r)/2);
            update(a,b,k*2+2,p,(l+r)/2,r);
        }
    }
};




void solve(){
    ll _n,d,a;
    ll x[200010],h[200010];
    cin>>_n>>d>>a;
    rep(i,_n) cin>>x[i]>>h[i];
    pll p[200010];
    rep(i,_n) p[i]={x[i],h[i]};
    sort(p,p+_n);
    vll v;
    map<ll,ll> mp;
    ll ans=0;

    SegmentTree sg(_n);


    rep(i,_n){
        if(i!=0){
            if(lower_bound(v.begin(),v.end(),p[i].fi)!=v.end()){
                ll k=LB(v,p[i].fi);
                
                p[i].sc-=sg.query(k)*a;
                // cout<<i<<" "<<k<<p[i].sc<<endl;
            }
        }
        if(p[i].sc<=0) continue;
        ll cnt=p[i].sc/a+(p[i].sc%a!=0);
        if(cnt<=0) continue;
        // cout<<i<<"cnt;"<<cnt<<endl;
        ans+=cnt;
        v.pb(p[i].fi+d*2);
        sg.update(0,i+1,0,cnt,0,n);
    }
    cout<<ans<<endl;

    

}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


Compiler output:
a.cc:28:9: warning: "ll" redefined
   28 | #define ll int
      |         ^~
a.cc:2:9: note: this is the location of the previous definition
    2 | #define ll long long
      |         ^~
a.cc:27:13: error: 'll' does not name a type
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:30:7: note: in expansion of macro 'll'
   30 | const ll INF = (1 << 30 ) - 1;
      |       ^~
a.cc:27:13: error: 'll' does not name a type
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:31:7: note: in expansion of macro 'll'
   31 | const ll LLINF = (1LL << 60LL);
      |       ^~
a.cc:27:13: error: 'll' does not name a type
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:32:7: note: in expansion of macro 'll'
   32 | const ll MOD = 1000000007;
      |       ^~
a.cc:27:13: error: 'll' does not name a type
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:33:7: note: in expansion of macro 'll'
   33 | const ll mod = 998244353;
      |       ^~
a.cc:27:13: error: 'll' does not name a type
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:34:7: note: in expansion of macro 'll'
   34 | const ll MAX = 1100000;
      |       ^~
a.cc:27:13: error: 'll' does not name a type
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:37:1: note: in expansion of macro 'll'
   37 | ll dx[8] ={1,0,-1,0,1,-1,1,-1};
      | ^~
a.cc:27:13: error: 'll' does not name a type
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:38:1: note: in expansion of macro 'll'
   38 | ll dy[8] ={0,1,0,-1,1,-1,-1,1};
      | ^~
a.cc: In function 'void solve()':
a.cc:27:13: error: 'll' was not declared in this scope
   27 | #define int ll
      |             ^~
a.cc:28:12: note: in expansion of macro 'int'
   28 | #define ll int
      |            ^~~
a.cc:83:5: note: in expansion of macro 'll'
   83 |     ll _n,d,a;
      |     ^~
a.cc:84:8: error: expected ';' before 'x'
   84 |     ll x[200010],h[200010];
      |        ^
a.cc:85:10: error: '_n' was not declared in this scope; did you mean 'yn'?
   85 |     cin>>_n>>d>>a;
      |          ^~
      |          yn
a.cc:85:14: error: 'd' was not declared in this scope
   85 |     cin>>_n>>d>>a;
      |              ^
a.cc:85:17: error: 'a' was not declared in this scope
   85 |     cin>>_n>>d>>a;
      |                 ^
a.cc:86:9: error: expected ';' before 'i'
   86 |     rep(i,_n) cin>>x[i]>>h[i];
      |         ^
a.cc:17:25: note: in definition of macro 'rep'
   17 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                         ^
a.cc:86:9: error: 'i' was not declared in this scope; did you mean 'pi'?
   86 |     rep(i,_n) cin>>x[i]>>h[i];
      |         ^
a.cc:17:29: note: in definition of macro 'rep'
   17 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                             ^
a.cc:86:20: error: 'x' was not declared in this scope
   86 |     rep(i,_n) cin>>x[i]>>h[i];
      |                    ^
a.cc:86:26: error: 'h' was not declared in this scope
   86 |     rep(i,_n) cin>>x[i]>>h[i];
      |                          ^
a.cc:88:9: error: expected ';' before 'i'
   88 |     rep(i,_n) p[i]={x[i],h[i]};
      |         ^
a.cc:17:25: note: in definition of macro 'rep'
   17 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                         ^
a.cc:88:9: error: 'i' was not declared in this scope
   88 |     rep(i,_n) p[i]={x[i],h[i]};
      |         ^
a.cc:17:29: note: in definition of macro 'rep'
   17 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                             ^
a.cc:88:21: error: 'x' was not declared in this scope
   88 |     rep(i,_n) p[i]={x[i],h[i]};
      |                     ^
a.cc:88:26: error: 'h' was not declared in this scope
   88 |     rep(i,_n) p[i]={x[i],h[i]};
      |                          ^
a.cc:9:22: error: template argument 2 is invalid
    9 | #define vll vector<ll>
      |                      ^
a.cc:90:5: note: in expansion of macro 'vll'
   90 |     vll v;
      |     ^~~
a.cc:91:14: error: template argument 3 is invalid
   91 |     map<ll,ll> mp;
      |              ^
a.cc:91:14: error: template argument 4 is invalid
a.cc:92:8: error: expected ';' before 'ans'
   92 |     ll ans=0;
      |        ^~~
a.cc:97:9: error: expected ';' before 'i'
   97 |     rep(i,_n){
      |         ^
a.cc:17:25: note: in definition of macro 'rep'
   17 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                         ^
a.cc:97:9: error: 'i' was not declared in this scope
   97 |     rep(i,_n){
      |         ^
a.cc:17:29: note: in definition of macro 'rep'
   17 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                             ^
a.cc:99:30: error: request for member 'begin' in 'v', which is of non-class type 'int'
   99 |             if(lower_bound(v.begin(),v.end(),p[i].fi)!=v.end()){
      |                              ^~~~~
a.cc:99:40: error: request for member 'end' in 'v', which is of non-class type 'int'
   99 |             if(lower_bound(v.begin(),v.end(),p[i].fi)!=v.end()){
      |                                        ^~~
a.cc:99:58: error: request for member 'end' in 'v', which is of non-class type 'int'
   99 |             if(lower_bound(v.begin(),v.end(),p[i].fi)!=v.end()){
      |                                                          ^~~
a.cc:100:20: error: expected ';' before 'k'
  100 |                 ll k=LB(v,p[i].fi);
      |                    ^
a.cc:102:35: error: 'k' was not declared in this scope
  102 |                 p[i].sc-=sg.query(k)*a;
      |                                   ^
a.cc:107:12: error: expected ';' before 'cnt'
  107 |         ll cnt=p[i].sc/a+(p[i].sc%a!=0);
      |            ^~~
a.cc:108:12: error: 'cnt' was not declared in this scope; did you mean 'int'?
  108 |         if(cnt<=0) continue;
      |            ^~~
      |            int
a.cc:110:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
  110 |         ans+=cnt;
      |         ^~~
      |         abs
a.cc:110:14: error: 'cnt' was not declared in this scope; did you mean 'int'?
  110 |         ans+=cnt;
      |              ^~~
      |              int
a.cc:13:12: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   13 | #define pb push_back
      |            ^~~~~~~~~
a.cc:111:11: note: in expansion of macro 'pb'
  111 |         v.pb(p[i].fi+d*2);
      |           ^~
a.cc:114:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
  114 |     cout<<ans<<endl;
      |           ^~~
      |           abs