Language: C++

#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<int,int>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> D >> A;
  Vec(P,pint,N+1,pint(0,0));
  rep(i,0,N){
    cin >> P[i].first >> C;
    flag=0;
    if(C%A!=0)flag++;
    P[i].second=C/A+flag;
  }
  P[N]=pint(INF,INF);
  Sort(P);
  rep(i,0,N){
    if(P[i].second==0)continue;
    else{
      int ok=P[i].first+D+D;
      int j=i+1;
      int k=INF;
      while(P[j].first<=ok){
        P[j].second=max(P[j].second-P[i].second,0LL);
        j++;
        if(P[j].second!=0)chmin(k,j);
      }
      chmin(j,k);
      sum+=P[i].second;
      i=j-1;
    }
  }
  Out(sum);
}

  


Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: warning: overflow in conversion from 'long int' to 'int' changes value from '9999999999' to '1410065407' [-Woverflow]
    8 | #define INF 9999999999
      |             ^~~~~~~~~~
a.cc:47:13: note: in expansion of macro 'INF'
   47 |       int k=INF;
      |             ^~~
a.cc:49:24: error: no matching function for call to 'max(int, long long int)'
   49 |         P[j].second=max(P[j].second-P[i].second,0LL);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:49:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   49 |         P[j].second=max(P[j].second-P[i].second,0LL);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:49:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   49 |         P[j].second=max(P[j].second-P[i].second,0LL);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~