Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ins insert
#define int long long int
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i = 0 ; i < n ; i++ )
#define f1(i,n) for(int  i = 1 ; i <= n ; i++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() int t;cin>>t;while(t--)
int mpower(int x, int y, int p){int res = 1;x = x % p;while(y > 0){if(y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
int power(int x, int y){int res = 1;while (y > 0){if (y & 1) res = res*x;y = y>>1;x = x*x;}return res;}
bool isPrime(int n){if (n <= 1)  return false;if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false;int p=sqrt(n);for(int i=5;i<=p;i=i+6)if (n%i == 0 || n%(i+2) == 0)return false;return true;}

bool q(pair<int,int> a, pair<int,int> b)
{
    return a.ss > b.ss;
    
}

int32_t main()
{
	fast();

	/*test()
	{
	}*/
    int n , k ;
    cin >> n >> k ;
    int a[n+1];
    
    f1(i,n) 
        cin >> a[i];
        
    int dp[n+1] = {0};
    
    for(int i = 2 ; i<= n ; i++)
    {
        int mn  = INT_MAX;
        for(int j = i-1 ; j>=1 && j >= i-k ; j--)
        {
            mn  = min(dp[j] + abs(a[j] - a[i]));
        }
        dp[j] = mn;
    }
    
    cout<<dp[n];


	return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:44:22: error: no matching function for call to 'min(long long int)'
   44 |             mn  = min(dp[j] + abs(a[j] - a[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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:44:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   44 |             mn  = min(dp[j] + abs(a[j] - a[i]));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
a.cc:46:12: error: 'j' was not declared in this scope
   46 |         dp[j] = mn;
      |            ^