Language: C++

#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 210000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};

int zz[MAX][3];
int dp[MAX][3];
void solve() {

	LL result = 0;
	int n;

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

	for (int i=1; i<n; ++i) {
		for (int j=0; j<3; ++j)  {
			for (int k=0; k<3; ++k) {
				if (j==k) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k])
			}
			dp[i][j] += zz[i][j];
		}
	}
	for (int j=0; j<3; ++j)  {
		result = max(result, dp[n-1][j]);
	}	
	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

Compiler output:
a.cc: In function 'void solve()':
a.cc:44:69: error: expected ';' before '}' token
   44 |                                 dp[i][j] = max(dp[i][j], dp[i-1][k])
      |                                                                     ^
      |                                                                     ;
   45 |                         }
      |                         ~                                            
a.cc:50:29: error: no matching function for call to 'max(LL&, int&)'
   50 |                 result = max(result, dp[n-1][j]);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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:2:
/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:50:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   50 |                 result = max(result, dp[n-1][j]);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:10:
/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:50:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   50 |                 result = max(result, dp[n-1][j]);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~