Language: C++

#include <bits/stdc++.h>
using namespace std;
int n;
int dp[n][3];

int helper(int a[][3],int i,int j)
{
	if(i<0)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(j==0)
	return dp[i][j] = max(a[i][j]+helper(a,i-1,j+1),a[i][j]+helper(a,i-1,j+2) );
    else if(j==1)
	return dp[i][j] = max(a[i][j]+helper(a,i-1,j+1),a[i][j]+helper(a,i-1,j-1) );
    else if(j==2)
	return dp[i][j] = max(a[i][j]+helper(a,i-1,j-1),a[i][j]+helper(a,i-1,j-2) );
}
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  
  cin>>n;
  int a[n][3];

  for (int i = 0; i < n; ++i)
  {
  	for(int j=0;j<3;++j)
  	cin>>a[i][j];
  }

  for (int i = 0; i < n; ++i)
  {
  	for(int j=0;j<3;++j)
  		dp[i][j]=-1;
  }
  //  int ans=-1e9;
  // for(int j=0;j<3;j++)
  // {
  //    ans = max(ans,helper(a,n-1,j));
  // }
  int a=helper(a,n-1,0);
  int b=helper(a,n-1,1);
  int c=helper(a,n-1,2);
  cout<<max(max(a,b),c);
  return 0;
}

Compiler output:
a.cc:4:8: error: size of array 'dp' is not an integral constant-expression
    4 | int dp[n][3];
      |        ^
a.cc: In function 'int main()':
a.cc:45:7: error: conflicting declaration 'int a'
   45 |   int a=helper(a,n-1,0);
      |       ^
a.cc:27:7: note: previous declaration as 'int a [n][3]'
   27 |   int a[n][3];
      |       ^
a.cc:48:16: error: no matching function for call to 'max(int [n][3], int&)'
   48 |   cout<<max(max(a,b),c);
      |             ~~~^~~~~
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:48:16: note:   variable-sized array type 'int [n][3]' is not a valid template argument
   48 |   cout<<max(max(a,b),c);
      |             ~~~^~~~~
/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:48:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int (*)[3]'
   48 |   cout<<max(max(a,b),c);
      |             ~~~^~~~~
a.cc: In function 'int helper(int (*)[3], int, int)':
a.cc:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^