Language: C++

#include <iostream>
#include <algorithm>
 
int32_t N;
int32_t D[120];
int32_t A[120];
int32_t dp[100][0X80];
 
struct R_print {
    template<typename T>
    T operator=(T&& v) {
        std::cout << v << ')' << '\n'; return std::forward<T>(v);
    }
};
 
//i??\??????????????????¨????????????§???eatable_flag???i????????????i??????7???(???????????????)???
int32_t func(int l_pos, uint8_t eatable_flag)
{
    if (N <= l_pos) { return 0; }
    eatable_flag &= 0X7F;
    if (N <= l_pos + 7) {
        uint16_t mask = 0;
        for (int i = l_pos + 1; i < N; ++i) {
            mask <<= 1; mask |= 1;
        }
        eatable_flag &= mask;
    }
 
#ifdef DEBUG
    auto PARAM_PRINT = [&]() {
        std::cout << '(' << l_pos << ',';
        for (int i = 7 - 1; i >= 0; --i) {
            std::cout << ((eatable_flag & (1 << i)) ? '1' : '0');
        }
        std::cout << ','; };
#define RETURN PARAM_PRINT(); return R_print{}=
#else
#define RETURN return
#endif
 
    if (-1 != dp[l_pos][eatable_flag]) { return dp[l_pos][eatable_flag]; }
    auto eat = [l_pos, eatable_flag](int pos) {
        auto index = l_pos + pos + 1;
        int32_t v = 0;
        for (int i = -7; i <= 7; ++i) {
            auto rindex = index + i;
            if (rindex < 0 || N < rindex) { continue; }
            if (rindex < l_pos) {
                if (index <= rindex + D[rindex]) {
                    v += A[rindex];
                }
            }
            if (l_pos < rindex) {//0 < pos + 1  + i
                auto bit = pos + i;
                if (
                    (bit < 7) &&
 
                    (
                        ((eatable_flag & (1 << bit)) == 0) &&
                        (rindex - D[rindex] <= index && index <= rindex + D[rindex])
                    )
                     
                    ) {
                    v += A[rindex];
                }
            }
        }
        return v;
    };
    int32_t res = 0;
    for (int i = 0; i < 7; ++i) {
        if (eatable_flag & (1 << i)) {
            //l_pos??\????????£???????
            res = std::max(res, eat(i) + func(l_pos, eatable_flag & ~(1 << i)));
        }
    }
    //l_pos?????£???????
    auto nf = eatable_flag;
    int count = 0;
    while ((nf & 1) != 1) {
        ++count;
        nf |= 0X80; nf >>= 1;
    }
    ++count;
    nf |= 0X80; nf >>= 1;
    res = std::max(res, eat(-1) + func(l_pos + count, nf));
    RETURN dp[l_pos][eatable_flag] = res;
}
 
int main()
{
    for (auto& a : dp)for (auto& i : a) { i = -1; }
    std::cin >> N;
    for (int i = 0; i < N; ++i) {
        std::cin >> D[i];
    }
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }
    std::cout << func(0, 0X7FFF) << std::endl;
}

Compiler output:
a.cc:17:25: error: 'uint8_t' has not been declared
   17 | int32_t func(int l_pos, uint8_t eatable_flag)
      |                         ^~~~~~~
a.cc: In function 'int32_t func(int, int)':
a.cc:22:9: error: 'uint16_t' was not declared in this scope
   22 |         uint16_t mask = 0;
      |         ^~~~~~~~
a.cc:3:1: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    2 | #include <algorithm>
  +++ |+#include <cstdint>
    3 | 
a.cc:24:13: error: 'mask' was not declared in this scope
   24 |             mask <<= 1; mask |= 1;
      |             ^~~~
a.cc:26:25: error: 'mask' was not declared in this scope
   26 |         eatable_flag &= mask;
      |                         ^~~~