Language: C++

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double

#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll MOD = 1000 * 1000 * 1000 + 7;
using namespace std;



ll N;



ll p[100005];


ll dp[100005];


ll rec(ll idx,ll D)
{
  
if (idx+1>D-1)
return 0;  

if (dp[idx]!=INT_MAX)
return dp[idx];
else if (idx==N-2) 
return dp[idx]=min(abs(p[idx]-p[idx+1])+rec(idx+1,D),INT_MAX));
else
return dp[idx]=min(abs(p[idx]-p[idx+1])+rec(idx+1,D),abs(p[idx]-p[idx+2])+rec(idx+2,D));



}



int main()
{


fastio();

cin>>N;

for (int i=0;i<N;i++)
cin>>p[i];  

fill(dp,dp+N,INT_MAX);

ll k=rec(0, N);

cout<<k;
    
return 0;
}


Compiler output:
a.cc: In function 'long long int rec(long long int, long long int)':
a.cc:42:19: error: no matching function for call to 'min(long long int, int)'
   42 | return dp[idx]=min(abs(p[idx]-p[idx+1])+rec(idx+1,D),INT_MAX));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:42:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 | return dp[idx]=min(abs(p[idx]-p[idx+1])+rec(idx+1,D),INT_MAX));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:42:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 | return dp[idx]=min(abs(p[idx]-p[idx+1])+rec(idx+1,D),INT_MAX));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:42:62: error: expected ';' before ')' token
   42 | return dp[idx]=min(abs(p[idx]-p[idx+1])+rec(idx+1,D),INT_MAX));
      |                                                              ^
      |                                                              ;
a.cc:42:62: error: expected primary-expression before ')' token
a.cc:43:1: error: 'else' without a previous 'if'
   43 | else
      | ^~~~