Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int n, k;
ll H[100200];
ll mem[100200];
ll dp(int at){
    if(at >= n){
        return 10000000000;
    }
    if(at == n-1) return 0;
    if(mem[at] != -1) return mem[at];
    int ans = 10000000000;
    rep(i,1,k+1){
        ans = min(ans, abs(H[at]-H[at+i])+dp(at+i));
    }
    return mem[at] = ans;
}

int main()
{
    cin.sync_with_stdio(false);
    memset(mem, -1, sizeof(mem));
    rep(i,0,100200) H[i] = -10000000000;
    cin >> n >> k;
    rep(i,0,n) cin >> H[i];
    cout << dp(0) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'll dp(int)':
a.cc:27:15: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   27 |     int ans = 10000000000;
      |               ^~~~~~~~~~~
a.cc:29:18: error: no matching function for call to 'min(int&, long long int)'
   29 |         ans = min(ans, abs(H[at]-H[at+i])+dp(at+i));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:29:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |         ans = min(ans, abs(H[at]-H[at+i])+dp(at+i));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:29:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |         ans = min(ans, abs(H[at]-H[at+i])+dp(at+i));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~