Language: C++

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll) INF;
ll dp[100001];
int N , E , T;
int a[100001];
ll dpRMQ[100001];
int opt = 0;
ll cost(int i , int opt)
{
	ll prev = 0;

	prev = dp[opt - 1];

	ll cur = max((a[i] - a[opt]) * 2 , T);

	return prev + cur;
}
int findOpt(int idx)
{
	return lower_bound(a , a + N , a[idx] - T / 2) - a;
}
ll findDp(int idx)
{
	int opt = findOpt(idx);
	//cout << opt << endl;
	ll dp1 = T;
	if(opt - 1 >= 0)
		dp1 += dp[opt - 1];
	ll dp2 = a[idx] * 2;
	if(opt - 1 >= 0)
		dp2 += min(dpRMQ[opt - 1] , 0);
	//cout << dp1 << " " << dp2 << endl;
	//if(opt < idx)
		return(min(dp1 , dp2));
	//else
		//return dp2;
}
int main()
{
	scanf("%d %d %d" , &N , &E , &T);
	for(int i = 0; i < N; i++)
	{
		scanf("%d" , &a[i]);
	}
	dp[0] = T;
	dpRMQ[0] = - a[0] * 2;
	for(int i = 1; i < N; i++)
	{
		dp[i] = findDp(i);
		dpRMQ[i] = min(dpRMQ[i - 1] , dp[i - 1] - a[i] * 2);
	}
	cout << dp[N - 1] + E;
}




Compiler output:
a.cc: In function 'll findDp(int)':
a.cc:49:27: error: no matching function for call to 'min(ll&, int)'
   49 |                 dp2 += min(dpRMQ[opt - 1] , 0);
      |                        ~~~^~~~~~~~~~~~~~~~~~~~
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:49:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   49 |                 dp2 += min(dpRMQ[opt - 1] , 0);
      |                        ~~~^~~~~~~~~~~~~~~~~~~~
/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:49:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   49 |                 dp2 += min(dpRMQ[opt - 1] , 0);
      |                        ~~~^~~~~~~~~~~~~~~~~~~~