Submission #596660

#TimeUsernameProblemLanguageResultExecution timeMemory
596660jayser6Knapsack (NOI18_knapsack)C++14
Compilation error
0 ms0 KiB
/*____________________________________________________________
// started : 07/13/22
// finished:
// problem : https://oj.uz/problem/view/NOI18_knapsack and file:///C:/Users/jayse/Downloads/statement_en.pdf
____________________________________________________________*/

#include <bits/stdc++.h>

#define FOR(n) for (int i = 0;i < n;i++)
#define FORO(n) for (int i = 1;i < n;i++)
#define ROF(n) for (int i = n - 1;i >= 0;i--)
#define ROFO(n) for (int i = n - 1;i >= 1;i--)
#define loop while (true) // rust woooo
#define ALL(arr) arr.begin(), arr.end()
#define lower lower_bound 
#define upper upper_bound
#define ll long long
#define uint unsigned int
#define hashmap unordered_map
#define hashset unordered_set
#define p_queue priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define BIG_NUMBER 1e18
#define BIG_PRIME 999998727899999 // this number has 15 digits
#define PRIME32 1e9 + 7 
#define ASCII_PRIME 257
#define ALPHA_PRIME 29

using namespace std;

struct DP {
    ll val;

    // the weight of the previous item that we landed on the dp state with, the
    // index of the item in the vector, the number of specific items already
    // bought
    int weight, wI, cnt;

    DP() {
        val = -1;
    }
    DP(ll val, int weight, int wI, int cnt) {
        this->val = val;
        this->weight = weight;
        this->wI = wI;
        this->cnt = cnt;
    }
};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // maxWeight is S from the problem statement, can't use s as variable name
    // because macro though
    int maxWeight, n; cin >> maxWeight >> n;

    // key -> weight, e.f -> val, e.s -> cnt. Sorted in descending order
    map<int, vector<pair<int, int>>, greater<int>()> items;
    FOR(n) {
        int val, weight, cnt; cin >> val >> weight >> cnt;
        if (weight <= maxWeight) {
            items[weight].pb({ val, cnt });
        }
    }

    vector<DP> dp(maxWeight + 1);
    for (auto& curr : items) {
        sort(ALL(curr.s), greater<pair<int, int>>());
        dp[curr.f] = DP(curr.s[0].f, curr.f, 0, 1);
    }

    FOR(maxWeight + 1) {
        if (dp[i].val == -1) {
            continue;
        }

        // transition
        bool isStart = true;
        for (auto j = items.find(dp[i].weight);j != items.end();j++) {
            int newWeight = i + j->f;
            if (newWeight > maxWeight) {
                // can't add this item, try a lighter item
                isStart = false;
                continue;
            }

            if (isStart) {
                isStart = false;

                if (dp[i].cnt == j->s[dp[i].wI].s) {
                    // all of this particular item is taken
                    if (dp[i].wI < j->s.size() - 1) {
                        // there are still items of this particular weight left
                        ll newVal = dp[i].val + j->s[dp[i].wI + 1].f;
                        if (newVal > dp[newWeight].val && j->f >= dp[newWeight].weight) {
                            dp[newWeight] = DP(newVal, j->f, dp[i].wI + 1, 1);
                        }
                    }
                }
                else {
                    ll newVal = dp[i].val + j->s[dp[i].wI].f;
                    if (newVal > dp[newWeight].val) {
                        dp[newWeight] = DP(newVal, j->f, dp[i].wI, dp[i].cnt + 1);
                    }

                }
            }
            else {
                ll newVal = dp[i].val + j->s[0].f;
                if (newVal > dp[newWeight].val) {
                    dp[newWeight] = DP(newVal, j->f, 0, 1);
                }
            }
        }
    }

    ll ans = 0;
    FOR(maxWeight + 1) {
        ans = max(ans, dp[i].val);
    }

    cout << ans;

    return 0;
}

Compilation message (stderr)

In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h: In instantiation of 'struct std::_Rb_tree_key_compare<std::greater<int>()>':
/usr/include/c++/10/bits/stl_tree.h:677:9:   required from 'struct std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >::_Rb_tree_impl<std::greater<int>(), false>'
/usr/include/c++/10/bits/stl_tree.h:720:31:   required from 'class std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >'
/usr/include/c++/10/bits/stl_map.h:153:17:   required from 'class std::map<int, std::vector<std::pair<int, int> >, std::greater<int>()>'
knapsack.cpp:64:54:   required from here
/usr/include/c++/10/bits/stl_tree.h:144:21: error: data member 'std::_Rb_tree_key_compare<std::greater<int>()>::_M_key_compare' invalidly declared function type
  144 |       _Key_compare  _M_key_compare;
      |                     ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h: In instantiation of 'class std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >':
/usr/include/c++/10/bits/stl_map.h:153:17:   required from 'class std::map<int, std::vector<std::pair<int, int> >, std::greater<int>()>'
knapsack.cpp:64:54:   required from here
/usr/include/c++/10/bits/stl_tree.h:998:7: error: function returning a function
  998 |       key_comp() const
      |       ^~~~~~~~
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_map.h: In instantiation of 'class std::map<int, std::vector<std::pair<int, int> >, std::greater<int>()>':
knapsack.cpp:64:54:   required from here
/usr/include/c++/10/bits/stl_map.h:1142:7: error: function returning a function
 1142 |       key_comp() const
      |       ^~~~~~~~
knapsack.cpp: In function 'int main()':
knapsack.cpp:98:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |                     if (dp[i].wI < j->s.size() - 1) {
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) [with _Key = int; _Val = std::pair<const int, std::vector<std::pair<int, int> > >; _KeyOfValue = std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >; _Compare = std::greater<int>(); _Alloc = std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >::iterator]':
/usr/include/c++/10/bits/stl_map.h:1170:25:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::find(const key_type&) [with _Key = int; _Tp = std::vector<std::pair<int, int> >; _Compare = std::greater<int>(); _Alloc = std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >::iterator; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]'
knapsack.cpp:85:46:   required from here
/usr/include/c++/10/bits/stl_tree.h:2555:33: error: too many arguments to function
 2555 |        || _M_impl._M_key_compare(__k,
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~        
/usr/include/c++/10/bits/stl_tree.h:2555:8: error: no match for 'operator||' (operand types are 'bool' and 'std::greater<int>')
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h:2555:8: note: candidate: 'operator||(bool, bool)' (built-in)
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   no known conversion for argument 2 from 'std::greater<int>' to 'bool'
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)'
  416 |     _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  416 |     _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  416 |     _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   'std::greater<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)'
  416 |     _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  416 |     _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   'std::greater<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/valarray:1196:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_or, _Tp>::result_type> std::operator||(const std::valarray<_Tp>&, const std::valarray<_Tp>&)'
 1196 | _DEFINE_BINARY_OPERATOR(||, __logical_or)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1196:1: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   mismatched types 'const std::valarray<_Tp>' and 'bool'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/valarray:1196:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__logical_or, _Tp>::result_type> std::operator||(const std::valarray<_Tp>&, const typename std::valarray<_Tp>::value_type&)'
 1196 | _DEFINE_BINARY_OPERATOR(||, __logical_or)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1196:1: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   mismatched types 'const std::valarray<_Tp>' and 'bool'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/valarray:1196:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_or, _Tp>::result_type> std::operator||(const typename std::valarray<_Tp>::value_type&, const std::valarray<_Tp>&)'
 1196 | _DEFINE_BINARY_OPERATOR(||, __logical_or)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/valarray:1196:1: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/stl_tree.h:2555:8: note:   'std::greater<int>' is not derived from 'const std::valarray<_Tp>'
 2554 |       return (__j == end()
      |              ~~~~~~~~~~~~~
 2555 |        || _M_impl._M_key_compare(__k,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2556 |      _S_key(__j._M_node))) ? end() : __j;
      |      ~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h: In instantiation of 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_hint_unique_pos(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, const key_type&) [with _Key = int; _Val = std::pair<const int, std::vector<std::pair<int, int> > >; _KeyOfValue = std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >; _Compare = std::greater<int>(); _Alloc = std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >::const_iterator; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = int]':
/usr/include/c++/10/bits/stl_tree.h:2465:19:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const int&>, std::tuple<>}; _Key = int; _Val = std::pair<const int, std::vector<std::pair<int, int> > >; _KeyOfValue = std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >; _Compare = std::greater<int>(); _Alloc = std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >::iterator; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree<int, std::pair<const int, std::vector<std::pair<int, int> > >, std::_Select1st<std::pair<const int, std::vector<std::pair<int, int> > > >, std::greater<int>(), std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > > >::const_iterator]'
/usr/include/c++/10/bits/stl_map.h:501:37:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = std::vector<std::pair<int, int> >; _Compare = std::greater<int>(); _Alloc = std::allocator<std::pair<const int, std::vector<std::pair<int, int> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<std::pair<int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]'
knapsack.cpp:68:25:   required from here
/usr/include/c++/10/bits/stl_tree.h:2204:33: error: too many arguments to function
 2204 |        && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k))
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h:2204:8: error: no match for 'operator&&' (operand types are 'bool' and 'std::greater<int>')
 2203 |    if (size() > 0
      |        ~~~~~~~~~~
 2204 |        && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k))
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h:2204:8: note: candidate: 'operator&&(bool, bool)' (built-in)
/usr/include/c++/10/bits/stl_tree.h:2204:8: note:   no known conversion for argument 2 from 'std::greater<int>' to 'bool'
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from knapsack.cpp:7:
/usr/include/c++/10/bits/valarray_after.h:415:5: note: