Language: C++

#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
ll dp[30000000];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> a(3),b(3);
    rep(i,3)cin >> a[i];
    rep(i,3)cin >> b[i];
    ll mx = 0;
    rep(i,3){
        for(int j=0;j<=N;j++){
            dp[j] = max(j,dp[j]);
            if(j-a[i]>=0){
                dp[j] = max(dp[j],dp[j-a[i]] + b[i]);
            }
        }
    }
    mx = dp[N];
    rep(i,5000*5000 + 1){
        dp[i] = 0;
    }
    rep(i,3){
        for(int j=0;j<=mx;j++){
            dp[j] = max(j,dp[j]);
            if(j-b[i]>=0){
                dp[j] = max(dp[j],dp[j-b[i]] + a[i]);
            }
        }
    }
    cout << dp[mx] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:24: error: no matching function for call to 'max(int&, long long int&)'
   24 |             dp[j] = max(j,dp[j]);
      |                     ~~~^~~~~~~~~
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: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:24:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |             dp[j] = max(j,dp[j]);
      |                     ~~~^~~~~~~~~
/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:24:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |             dp[j] = max(j,dp[j]);
      |                     ~~~^~~~~~~~~
a.cc:36:24: error: no matching function for call to 'max(int&, long long int&)'
   36 |             dp[j] = max(j,dp[j]);
      |                     ~~~^~~~~~~~~
/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:36:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   36 |             dp[j] = max(j,dp[j]);
      |                     ~~~^~~~~~~~~
/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
/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:36:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   36 |             dp[j] = max(j,dp[j]);
      |                     ~~~^~~~~~~~~