Problem 01knapsack
User Hengweezy
Submission Time 2024-02-13 23:25:13
Score 0
Max Time N/A
Max Memory N/A

Compile Error

01knapsack.cpp: In function ‘int main()’:
01knapsack.cpp:13:5: error: request for member ‘push_back’ in ‘v’, which is of non-class type ‘int’
13 | v.push_back(make_pair(w, v));
| ^~~~~~~~~
01knapsack.cpp:20:27: error: no match for ‘operator+’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type’ {aka ‘std::pair<int, int>’} and ‘int’)
20 | if(v[j] < v[j- weight] + value){
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
from /usr/include/c++/9/bits/specfun.h:45,
from /usr/include/c++/9/cmath:1927,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
from 01knapsack.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:423:5: note: candidate: ‘template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename std::revers