Language: C++

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

#define int long long
int N;
int h[100000];
int dp[100000];

int solve(int now){
	if(now == N-1) return 0;
	if(now >= N) return INT_MAX;
	if(dp[now] != INT_MAX) return dp[now];
	int a = abs(h[now]-h[now+1]) + solve(now+1);
	if(a == abs(h[now]-h[now+1]) - 1) a = INT_MAX;
	int b = abs(h[now]-h[now+2]) + solve(now+2);
	if(b == abs(h[now]-h[now+2]) - 1) b = INT_MAX;
	return dp[now] = min(INT_MAX,min(a,b));
}

#undef int

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	h[N] = 0;
	cout << solve(0) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(long long int)':
a.cc:45:29: error: no matching function for call to 'min(int, const long long int&)'
   45 |         return dp[now] = min(INT_MAX,min(a,b));
      |                          ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:45:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |         return dp[now] = min(INT_MAX,min(a,b));
      |                          ~~~^~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:16:
/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:45:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |         return dp[now] = min(INT_MAX,min(a,b));
      |                          ~~~^~~~~~~~~~~~~~~~~~