Language: C++

#include <bits/stdc++.h>

#define pb push_back
#define ll long long

using namespace std;

const int N = 2e5 + 123, MAXN = 1e9;

ll n, d, a;

ll t[50 * N], mn[50 * N], add[50 * N], L[50 * N], R[50 * N], sz = 1;
ll ans;

inline void push (int v, int tl, int tr) {
    if (add[v]) {
        t[v] += add[v];
        if (tl != tr) {
            if (!L[v])L[v] = ++ sz;
            if (!R[v])R[v] = ++ sz;
            add[L[v]] += add[v];
            add[R[v]] += add[v];
        }
        add[v] = 0;
    }
}

void upd (int l, int r, ll val, int v = 1, int tl = 1, int tr = MAXN) {
    push (v, tl, tr);
    if (tl > r || l > tr || !v)return;
    if (tl >= l && r >= tr) {
        add[v] += val;
        push (v, tl, tr);
        return;
    }int tm = (tl + tr) >> 1;
    if (!L[v])L[v] = ++ sz;
    if (!R[v])R[v] = ++ sz;
    upd (l, r, val, L[v], tl, tm);
    upd (l, r, val, R[v], tm + 1, tr);
    t[v] = t[L[v]] + t[R[v]];
}

ll get (int pos, int v = 1, int tl = 1, int tr = MAXN) {
    push (v, tl, tr);
    if (tl == tr)return t[v];
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
        return get (pos, L[v], tl, tm);
    }else {
        return get (pos, R[v], tm + 1, tr);
    }
}

vector <int> v;

int main () {
    scanf("%lld%lld%lld", &n, &d, &a);
    for (ll i = 0, x, h;i < n;i ++) {
        scanf("%lld%lld", &x, &h);
        upd (x, x, h);
        v.pb (x);
    }sort (v.begin (), v.end ());
    for (auto it : v) {
        ll val = get (it), need;
        if (val > 0) {
            need = val / a + (val % a > 0);
            ans += need * 1ll;
            upd (it, min (it + 2 * d, MAXN), (need * a * -1ll));
        }
    }
    printf("%lld", ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:68:26: error: no matching function for call to 'min(long long int, const int&)'
   68 |             upd (it, min (it + 2 * d, MAXN), (need * a * -1ll));
      |                      ~~~~^~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:68:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   68 |             upd (it, min (it + 2 * d, MAXN), (need * a * -1ll));
      |                      ~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:68:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   68 |             upd (it, min (it + 2 * d, MAXN), (need * a * -1ll));
      |                      ~~~~^~~~~~~~~~~~~~~~~~