Language: C++

#include <bits/stdc++.h>

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll n,d,a,x,h;
    cin >> n >> d >> a;

    vector<pair<ll, ll>> v;

    rep(i, n){
        cin >> x >> h;
        v.pback(mpair(x, h));
    }

    sort(ALL(v));

    vector<pair<ll,ll>> v2(1, mpair(-1, 0)); //vを座標圧縮したものx座標が隣でないなら、間に1つ区切りをいれるようにする

    v2.pback(v[0]);

    ll oldx = v[0].first;
    ll oldh = v[0].second;

    rep(i, n - 1){

        if(v[i + 1].first - oldx == 1){
            v2.pback(v[i + 1]);
        }else{
            v2.pback(mpair(v2[v2.size() - 1].first + 1, 0));
            v2.pback(v[i + 1]);
        }

        oldx = v[i + 1].first;
        oldh = v[i + 1].second;
    }

    v2.pback(mpair(v2[v2.size() - 1].first + 1, 0));

    int v2size = v2.size();

    vector<ll> imos(v2size); //爆弾の範囲攻撃のダメージをimos法で管理

    ll ans = 0;

    for(int i = 1; i < v2size - 1; i++){

        imos[i] = imos[i] + imos[i - 1];

        ll tmpx = v2[i].first;
        ll tmph = v2[i].second - imos[i];

        if(tmph > 0){

            ll bombcount = (tmph + (a - 1)) / a;
            ll right = tmpx + (2 * d) + 1; //爆発範囲の上限ではなくそれより+1したもの

            auto itr = lower_bound(ALL(v2), mpair(right, LLONG_MAX));
            ll index = min(itr - v2.begin(), v2size - 1);

            imos[i] += bombcount * a;
            imos.at(index) -= bombcount * a;

            //cerr << "bomb " <<  tmpx << " "  << right << " " << bombcount << endl;
            //cerr << "right index " << index << endl;

            ans += bombcount;

        }

    }

    /*
    rep(i, v2size){
        cerr << v2[i].first << " " << v2[i].second << endl;
    }
    */


    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:27: error: no matching function for call to 'min(__gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >::difference_type, int)'
   70 |             ll index = min(itr - v2.begin(), v2size - 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: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:70:27: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   70 |             ll index = min(itr - v2.begin(), v2size - 1);
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:70:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   70 |             ll index = min(itr - v2.begin(), v2size - 1);
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~