Language: C++

#include<iostream>
#include<vector>
using namespace std;

vector<int> weight(105);
vector<int> value(105);
vector<vector<int>> select(105+1, vector<int>(1000+1,0));

int zeroOnePack(int N, int C, const vector<int>& weight, const vector<int>& value)
{
    for(int i = 1; i <= N; ++i)
    {
        for(int j = 1; j <= C; ++j)
        {
            if (weight[i - 1] > j)
                select[i][j] = select[i - 1][j];
            else
                select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
        }
    }
    return select[N][C];
}
int main()
{
    int n, c;
    scanf("%d %d", &n, &c);
    for(int i = 0; i < n; i++){
            int tw, tv;
        scanf("%d %d", &weight[i], &value[i]);
    }
    cout << zeroOnePack(n, c, weight, value) << endl;
    return 0;
}


Compiler output:
a.cc:7:27: error: 'std::vector<std::vector<int> > select' redeclared as different kind of entity
    7 | vector<vector<int>> select(105+1, vector<int>(1000+1,0));
      |                           ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:514,
                 from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  102 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
a.cc: In function 'int zeroOnePack(int, int, const std::vector<int>&, const std::vector<int>&)':
a.cc:16:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |                 select[i][j] = select[i - 1][j];
      |                         ^
a.cc:16:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |                 select[i][j] = select[i - 1][j];
      |                            ^
a.cc:16:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |                 select[i][j] = select[i - 1][j];
      |                                            ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:16:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |                 select[i][j] = select[i - 1][j];
      |                                               ^
a.cc:16:30: error: assignment of read-only location '*(select + (((sizetype)i) + ((sizetype)j)))'
   16 |                 select[i][j] = select[i - 1][j];
      |                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:18:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                         ^
a.cc:18:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                            ^
a.cc:18:48: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                                                ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:18:51: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                                                   ^
a.cc:18:66: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                                                                  ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:18:85: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                                                                                     ^
a.cc:18:87: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
a.cc:18:35: error: no matching function for call to 'max(int (&)(int, fd_set*, fd_set*, fd_set*, timeval*), int (*)(int, fd_set*, fd_set*, fd_set*, timeval*))'
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51:
/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:18:35: note:   deduced conflicting types for parameter 'const _Tp' ('int(int, fd_set*, fd_set*, fd_set*, timeval*)' and 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)')
   18 |                 select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]);
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
a.cc:21:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |     return select[N][C];
      |                    ^
a.cc:21:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |     return select[N][C];
      |                       ^
a.cc:21:23: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'int' [-fpermissive]
   21 |     return select[N][C];
      |                       ^
      |                       |
      |                       int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)