Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define pii pair < int , int >
#define Endl '\n'

#pragma GCC optimize("Ofast")

using namespace std;
using namespace __gnu_pbds;

template <typename T> using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const int FFTM = 998244353;

const int SX[4] = {0 , 1 , -1 , 0};
const int SY[4] = {1 , 0 , 0 , -1};
const int rx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int ry[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

typedef cc_hash_table< int, int, hash<int>, equal_to<int>, direct_mask_range_hashing<int>, hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;

const int N = 3001;

ll dp[90][N];

void clar(){
    for (int i = 0;i <= 89; ++i){
        for (int j = 0;j < N; ++j)dp[i][j] = -1;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("gotham.in", "r", stdin);
//    freopen("gotham.out", "w", stdout);
#endif
    int n;
    cin >> n;
    vector < ll > a(n + 1);
    for (int i = 1;i <= n; ++i){
        cin >> a[i];
    }
    clar();
    dp[0][0] = 1000;
    for (int i = 0;i <= n - 1; ++i){
        for (int st = 0;st < N; ++st){
            if (dp[i][st] == -1)continue;
            for (int delta = -st;delta < N; ++delta){
                int nst = st + delta;
                if (nst >= N)break;
                int sum = dp[i][st] - delta * a[i + 1];
                if (sum >= 0)dp[i + 1][nst] = max(dp[i + 1][nst], sum);
            }
        }
    }
    int ans = 0;
    for (int i = 0;i < N; ++i)
        if (dp[n][i] != -1)ans = max(ans, dp[n][i] + i * a[n]);
    cout << ans << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int32_t main()':
a.cc:74:50: error: no matching function for call to 'max(long long int&, int&)'
   74 |                 if (sum >= 0)dp[i + 1][nst] = max(dp[i + 1][nst], sum);
      |                                               ~~~^~~~~~~~~~~~~~~~~~~~~
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:74:50: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   74 |                 if (sum >= 0)dp[i + 1][nst] = max(dp[i + 1][nst], sum);
      |                                               ~~~^~~~~~~~~~~~~~~~~~~~~
/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:74:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   74 |                 if (sum >= 0)dp[i + 1][nst] = max(dp[i + 1][nst], sum);
      |                                               ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:80:37: error: no matching function for call to 'max(int&, long long int)'
   80 |         if (dp[n][i] != -1)ans = max(ans, dp[n][i] + i * a[n]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/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:80:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   80 |         if (dp[n][i] != -1)ans = max(ans, dp[n][i] + i * a[n]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/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:80:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   80 |         if (dp[n][i] != -1)ans = max(ans, dp[n][i] + i * a[n]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~