Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

ll DP[1001][20001];
int done[1001][20001];
vector<array<ll,4>>A;//[w+s][val][weight][cap]
ll n;

ll solve(int pos, int cap)
{
    if(cap ==0 || pos >= n)return 0;
    if(done[pos][cap])return DP[pos][cap];

    done[pos][cap]=1;
    if(A[pos][2] <= cap)DP[pos][cap] = A[pos][1] + solve(pos+1, min({cap-A[pos][2], A[pos][3], 10000}));
    DP[pos][cap]=max(DP[pos][cap], solve(pos+1,cap));
    return DP[pos][cap];
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    A.resize(n);
    for(int i=0; i<n; i++)
    {
        ll w,s,v; //w-block weight, s - block capacity to hold weight, v - value
        cin>>w>>s>>v;
        A[i]={w+s,v,w,s};
    }

    //lets say we have 2 blocks A(s1,w1) and B(s2,w2)
    //if we put A on B remaining cap is s2-w1
    //otherwise its s1-w2
    //so if block A should go on bottom s1-w2 > s2-w1 or s1+w1 > s2+w2

    sort(A.rbegin(),A.rend());
    cout<<solve(0,20000)<<"\n";
}


Compiler output:
a.cc: In function 'long long int solve(int, int)':
a.cc:18:68: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   18 |     if(A[pos][2] <= cap)DP[pos][cap] = A[pos][1] + solve(pos+1, min({cap-A[pos][2], A[pos][3], 10000}));
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:18:68: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'int')
   18 |     if(A[pos][2] <= cap)DP[pos][cap] = A[pos][1] + solve(pos+1, min({cap-A[pos][2], A[pos][3], 10000}));
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided