Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
const int N=5000*5000+1; 
int n,a,b,c,d,e,f,ans=0;
long long dp[N];
int main(){
	cin>>n>>a>>b>>c>>d>>e>>f;
	memset (dp,-1,sizeof(dp));
	dp[n]=n;
	for (int i=n;i<N;i++){
		if (dp[i]==-1) continue;
		if (a<d && dp[i]>=a) dp[i+d-a]=max(dp[i+d-a],dp[i]-a);
		if (b<e && dp[i]>=b) dp[i+e-b]=max(dp[i+e-a],dp[i]-b);
		if (c<f && dp[i]>=c) dp[i+f-c]=max(dp[i+f-c],dp[i]-c);
	}
	for (int i=n;i<N;i++){
		if (dp[i]==-1) continue;
		dp[i]=i;
	}
	for (int i=N;i>=0;i++){
		if (dp[i]==-1) continue;
		if (a>d && i>=d) dp[i-d]=max(dp[i-d],dp[i]+a-d);
		if (b>e && i>=e) dp[i-e]=max(dp[i-e],dp[i]+b-e);
		if (c>f && i>=f) dp[i-f]=max(dp[i-f],dp[i]+c-f);
		ans=max(ans,dp[i]);
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:24: error: no matching function for call to 'max(int&, long long int&)'
   53 |                 ans=max(ans,dp[i]);
      |                     ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:53:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   53 |                 ans=max(ans,dp[i]);
      |                     ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:53:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |                 ans=max(ans,dp[i]);
      |                     ~~~^~~~~~~~~~~