Language: C++

//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <tuple>
#include <utility>

namespace n91 {

void main_() {
  static constexpr u64 INF = std::numeric_limits<u64>::max() / 100;

  usize n;
  std::cin >> n;
  std::vector<u64> v(n);
  for (auto &e : v) {
    std::cin >> e;
  }
  using arg = std::tuple<usize, usize, u64, u64>;
  std::map<arg, u64> memo;
  const auto dp = [&](const auto &dp, const arg &a) -> u64 {
    if (!memo.count(a)) {
      usize l, r;
      u64 x, y;
      std::tie(l, r, x, y) = a;
      u64 min = INF;
      if (r - l == 1_z) {
        min = static_cast<u64>(0);
      } else if (x > INF || y > INF) {
        min = INF;
      } else {
        for (const auto m : rep(l + 1_z, r)) {
          min = std::min(min, dp(dp, {l, m, x, x + y}) +
                                  dp(dp, {m, r, x + y, y}) + v[m] * (x + y));
        }
      }
      memo[a] = min;
    }
    return memo[a];
  };
  std::cout << v[0_z] +
                   dp(dp,
                      {0_z, n - 1_z, static_cast<u64>(1), static_cast<u64>(1)}) +
                   v[n - 1_z]
            << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Compiler output:
a.cc: In function 'void n91::main_()':
a.cc:81:35: error: 'numeric_limits' is not a member of 'std'
   81 |   static constexpr u64 INF = std::numeric_limits<u64>::max() / 100;
      |                                   ^~~~~~~~~~~~~~
a.cc:81:53: error: expected primary-expression before '>' token
   81 |   static constexpr u64 INF = std::numeric_limits<u64>::max() / 100;
      |                                                     ^
a.cc:81:56: error: '::max' has not been declared; did you mean 'std::max'?
   81 |   static constexpr u64 INF = std::numeric_limits<u64>::max() / 100;
      |                                                        ^~~
      |                                                        std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:71:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~