Language: C++

#include <bits/stdc++.h>
#define endl '\n'
#define pii pair<int, int>

using namespace std;

int n, a;
int matriz[100005][5];
long long dp[100005][5];

void inicializar()
{
	for(int i = 0; i < 3; i++)
	{
		dp[0][i] = matriz[0][i];
	}
}

long long maximo()
{
	long long resp = 0;
	for(int i = 0; i < 3; i++)
	{
		resp = max(resp, dp[n - 1][i]);
	}
	return resp;
}

void imprimir()
{
    cout << "matriz" << endl;
    for(int i = 0; i  < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cout << matriz[i][j] << " ";
        }
        cout << endl;
    }

    cout << "dp" << endl;
    for(int i = 0; i  < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

long long vacation()
{
	inicializar();

	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			if(j == 0)
				dp[i][j] = matriz[i][j] + max(dp[i - 1][1], dp[i - 1][2]);
			else if(j == 1)
				dp[i][j] = matriz[i][j] + max(dp[i - 1][0], dp[i - 1][2]);
			else
				dp[i][j] = matriz[i][j] + max(dp[i - 1][0], dp[i - 1][1]);
		}
	}

    //imprimir();
	long long resp = maximo();
	return resp;
}

int main()
{
    cin >> n;

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

    long long resp = vacation();

    cout << resp << endl;
}
#include <bits/stdc++.h>
#define endl '\n'
#define pii pair<int, int>

using namespace std;

int n, a;
int matriz[100005][5];
long long dp[100005][5];

void inicializar()
{
	for(int i = 0; i < 3; i++)
	{
		dp[0][i] = matriz[0][i];
	}
}

long long maximo()
{
	long long resp = 0;
	for(int i = 0; i < 3; i++)
	{
		resp = max(resp, dp[n - 1][i]);
	}
	return resp;
}

void imprimir()
{
    cout << "matriz" << endl;
    for(int i = 0; i  < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cout << matriz[i][j] << " ";
        }
        cout << endl;
    }

    cout << "dp" << endl;
    for(int i = 0; i  < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

long long vacation()
{
	inicializar();

	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			if(j == 0)
				dp[i][j] = matriz[i][j] + max(dp[i - 1][1], dp[i - 1][2]);
			else if(j == 1)
				dp[i][j] = matriz[i][j] + max(dp[i - 1][0], dp[i - 1][2]);
			else
				dp[i][j] = matriz[i][j] + max(dp[i - 1][0], dp[i - 1][1]);
		}
	}

    //imprimir();
	long long resp = maximo();
	return resp;
}

int main()
{
    cin >> n;

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

    long long resp = vacation();

    cout << resp << endl;
}



Compiler output:
a.cc:97:5: error: redefinition of 'int n'
   97 | int n, a;
      |     ^
a.cc:7:5: note: 'int n' previously declared here
    7 | int n, a;
      |     ^
a.cc:97:8: error: redefinition of 'int a'
   97 | int n, a;
      |        ^
a.cc:7:8: note: 'int a' previously declared here
    7 | int n, a;
      |        ^
a.cc:98:5: error: redefinition of 'int matriz [100005][5]'
   98 | int matriz[100005][5];
      |     ^~~~~~
a.cc:8:5: note: 'int matriz [100005][5]' previously declared here
    8 | int matriz[100005][5];
      |     ^~~~~~
a.cc:99:11: error: redefinition of 'long long int dp [100005][5]'
   99 | long long dp[100005][5];
      |           ^~
a.cc:9:11: note: 'long long int dp [100005][5]' previously declared here
    9 | long long dp[100005][5];
      |           ^~
a.cc:101:6: error: redefinition of 'void inicializar()'
  101 | void inicializar()
      |      ^~~~~~~~~~~
a.cc:11:6: note: 'void inicializar()' previously defined here
   11 | void inicializar()
      |      ^~~~~~~~~~~
a.cc:109:11: error: redefinition of 'long long int maximo()'
  109 | long long maximo()
      |           ^~~~~~
a.cc:19:11: note: 'long long int maximo()' previously defined here
   19 | long long maximo()
      |           ^~~~~~
a.cc:119:6: error: redefinition of 'void imprimir()'
  119 | void imprimir()
      |      ^~~~~~~~
a.cc:29:6: note: 'void imprimir()' previously defined here
   29 | void imprimir()
      |      ^~~~~~~~
a.cc:142:11: error: redefinition of 'long long int vacation()'
  142 | long long vacation()
      |           ^~~~~~~~
a.cc:52:11: note: 'long long int vacation()' previously defined here
   52 | long long vacation()
      |           ^~~~~~~~
a.cc:164:5: error: redefinition of 'int main()'
  164 | int main()
      |     ^~~~
a.cc:74:5: note: 'int main()' previously defined here
   74 | int main()
      |     ^~~~