Language: C++

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 500050;
int N, Q, q[MAX_N];
long long D, d[MAX_N];

long long area[MAX_N], loc[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> D;

    for (int i = 1; i <= N; i++) {
        std::cin >> d[i];
    }

    std::cin >> Q;

    for (int i = 1; i <= Q; i++) {
        std::cin >> q[i];
    }

    area[N+1] = 0;
    for (int i = N; 1 <= i; i--) {
        if (d[i] <= area[i+1] * 2 + 1) {
            area[i] = area[i+1] + d[i];
        } else {
            area[i] = area[i+1];
        }
        //std::cout << i << " " << area[i] << std::endl;
    }

    loc[0] = D;
    for (int i = 1; i <= N; i++) {
        loc[i] = std::min(abs(loc[i-1] - d[i]), loc[i-1]);
        //std::cout << i << " " << loc[i] << std::endl;
    }

    for (int i = 1; i <= Q; i++) {
        if (loc[q[i]-1] > area[q[i]+1]) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:50:26: error: no matching function for call to 'min(int, long long int&)'
   50 |         loc[i] = std::min(abs(loc[i-1] - d[i]), loc[i-1]);
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/istream:40,
                 from /usr/include/c++/14/fstream:40,
                 from a.cc:3:
/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:50:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   50 |         loc[i] = std::min(abs(loc[i-1] - d[i]), loc[i-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,
                 from a.cc:5:
/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:50:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   50 |         loc[i] = std::min(abs(loc[i-1] - d[i]), loc[i-1]);
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~