Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

void solve(long long N, long long D, long long A, std::vector<pll> E) {
    sort(E.begin(), E.end());
    vl S(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        sum += E[i].second;
        S[i] = sum;
    }
    vi range(N);
    int min = 0;
    for (int i = 0; i < N; i++) {
        while (true) {
            if (E[min].first + 2 * D >= E[i].first) {
                range[i] = min;
                break;
            } else {
                min++;
            }
        }
    }

    ll ans = E[0].second;
    for (int i = 1; i < N; i++) {
        if (range[i] == 0) {
            ans += max(0LL, E[i].second - S[i - 1]);
        } else {
            ans += max(0LL, E[i].second - (S[i - 1] - S[range[i] - 1]));
        }
    }
    
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    long long N;
    std::cin >> N;
    long long D;
    std::cin >> D;
    long long A;
    std::cin >> A;
    vector<pll> E(N);
    for (int i = 0; i < N; i++) {
        ll x, h;
        std::cin >> x;
        std::cin >> h;
        ll play = h / A;
        if (h % A != 0) {
            play++;
        }
        E[i].first = x;
        E[i].second = play;
    }
    solve(N, D, A, std::move(E));
    return 0;
}


Compiler output:
a.cc: In function 'void solve(long long int, long long int, long long int, std::vector<std::pair<long int, long int> >)':
a.cc:80:23: error: no matching function for call to 'max(long long int, long int)'
   80 |             ans += max(0LL, E[i].second - S[i - 1]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:80:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   80 |             ans += max(0LL, E[i].second - S[i - 1]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:80:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   80 |             ans += max(0LL, E[i].second - S[i - 1]);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:82:23: error: no matching function for call to 'max(long long int, long int)'
   82 |             ans += max(0LL, E[i].second - (S[i - 1] - S[range[i] - 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:82:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   82 |             ans += max(0LL, E[i].second - (S[i - 1] - S[range[i] - 1]));
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:82:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   82 |             ans += max(0LL, E[i].second - (S[i - 1] - S[range[i] - 1]));
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~