Language: C++

#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, k;
    cin >> n >> k;
    vector<i64> h_s(n + 2, 0);
    rep(x, n)
    {
        cin >> h_s[x + 1];
    }

    constexpr i64 ansmax = 3'00'000'000'000;
    // dp[x][l] = [0,l]回変更しxは変更しないときの[0,x]までの最適値
    vector dp(n + 2, vector(k + 1, ansmax));
    dp[0] = vector(k + 1, 0LL);
    FOR(x, 1, n + 1)
    {
        rep(x2, x)
        {
            FOR(l, x - x2 - 1, k)
            {
                chmin(dp[x][l], dp[x2][l - (x - x2 - 1)] + max(0LL, h_s[x] - h_s[x2]));
            }
        }
    }
    cout << dp[n + 1][k] << '\n';

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:30: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long int> >, std::vector<long int> >::value_type' {aka 'std::vector<long int>'} and 'std::vector<long long int, std::allocator<long long int> >')
   83 |     dp[0] = vector(k + 1, 0LL);
      |                              ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:13:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<long long int, std::allocator<long long int> >' to 'const std::vector<long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<long long int, std::allocator<long long int> >' to 'std::vector<long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long int; _Alloc = std::allocator<long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<long long int, std::allocator<long long int> >' to 'std::initializer_list<long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:90:63: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   90 |                 chmin(dp[x][l], dp[x2][l - (x - x2 - 1)] + max(0LL, h_s[x] - h_s[x2]));
      |                                                            ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:11:
/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:90:63: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   90 |                 chmin(dp[x][l], dp[x2][l - (x - x2 - 1)] + max(0LL, h_s[x] - h_s[x2]));
      |                                                            ~~~^~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:25:
/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:90:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   90 |                 chmin(dp[x][l], dp[x2][l - (x - x2 - 1)] + max(0LL, h_s[x] - h_s[x2]));
      |                                                            ~~~^~~~~~~~~~~~~~~~~~~~~~~