Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2192212#1
struct StarrySky{
  static const ll MAX_N = 1LL << 17;
  ll datm[2LL*MAX_N],data[2LL*MAX_N],n;
  StarrySky(){}
  StarrySky(ll n_){init(n_);}
  void init(ll n_){
    n=1LL;
    while(n<n_) n*=2LL;
    for(ll i=0;i<n*2;i++) datm[i]=data[i]=0;
  }
  void add(ll a,ll b,ll x,ll k,ll l,ll r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      data[k]+=x;
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
    datm[k]=max(datm[k*2+1]+data[k*2+1],datm[k*2+2]+data[k*2+2]);
  }
  ll query(ll a,ll b,ll k,ll l,ll r){
    if(r<=a||b<=l) return 0;
    if(a<=l&&r<=b) return datm[k]+data[k];
    ll vl=query(a,b,k*2+1,l,(l+r)/2);
    ll vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr)+data[k];
  }
  void add(ll a,ll b,ll x){
    add(a,b,x,0,0,n);
  }
  ll query(ll a,ll b){
    return query(a,b,0,0,n);
  }
  ll query(ll a) {
    return query(a, a+1);
  }
};

ll f(ll a, ll b) {
  if (a%b == 0) {
    return a/b;
  } else {
    return a/b+1;
  }
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);

  ll n, d, a;
  cin >> n >> d >> a;
  vector<pll> v(n);
  rep(i, n) {
    cin >> v[i].first >> v[i].second;
  }

  sort(all(v));
  StarrySky ss(n*2);

  ll ans = 0;
  rep(i, n) {
    //rep(j, n) {
    //  cerr << ss.query(j) << " ";
    //}
    //cerr << endl;
    if (ss.query(i) < v[i].second) {
      ll t = f(v[i].second-ss.query(i), a);
      //cerr << v[i].second << " " << ss.query(i) << endl;
      //cerr << "t:" << t << endl;
      ans += t;
      ll c = upper_bound(all(v), pll(v[i].first+2*d, 1LL<<60))-v.begin();
      c = max(0, c-i);
      //cerr << i << " " << c << endl;
      ss.add(i, i+c, t*a);
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:85:14: error: no matching function for call to 'max(int, ll)'
   85 |       c = max(0, c-i);
      |           ~~~^~~~~~~~
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:85:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   85 |       c = max(0, c-i);
      |           ~~~^~~~~~~~
/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:85:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   85 |       c = max(0, c-i);
      |           ~~~^~~~~~~~