Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  vector<vector<int> > dp(n,vector<int>(3,0));
  dp[n-1][0]=max(b[n-1],c[n-1]);
  dp[n-1][1]=max(a[n-1],c[n-1]);
  dp[n-1][2]=max(b[n-1],a[n-1]);
  for(int i=n-2;i>=0;i--){
    if(b[i]==c[i]) dp[i][0]=max(b[i]+dp[i+1][1],b[i]+dp[i+1][2]);
    else dp[i][0]=max(dp[i+1][1]+b[i]:dp[i+1][2]+c[i]);
    
    if(a[i]==c[i]) dp[i][1]=max(c[i]+dp[i+1][0],c[i]+dp[i+1][2]);
    else dp[i][1]=max(dp[i+1][0]+a[i]:dp[i+1][2]+c[i]);
    
    if(b[i]==a[i]) dp[i][2]=max(b[i]+dp[i+1][1],b[i]+dp[i+1][0]);
    else dp[i][2]=max(dp[i+1][1]+b[i]:dp[i+1][0]+a[i]);
    
  }
  cout<<max(dp[0][1],max(dp[0][2],dp[0][0]));
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:38: error: expected ')' before ':' token
   17 |     else dp[i][0]=max(dp[i+1][1]+b[i]:dp[i+1][2]+c[i]);
      |                      ~               ^
      |                                      )
a.cc:17:22: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   17 |     else dp[i][0]=max(dp[i+1][1]+b[i]:dp[i+1][2]+c[i]);
      |                   ~~~^~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:17:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |     else dp[i][0]=max(dp[i+1][1]+b[i]:dp[i+1][2]+c[i]);
      |                   ~~~^~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
a.cc:20:38: error: expected ')' before ':' token
   20 |     else dp[i][1]=max(dp[i+1][0]+a[i]:dp[i+1][2]+c[i]);
      |                      ~               ^
      |                                      )
a.cc:20:22: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   20 |     else dp[i][1]=max(dp[i+1][0]+a[i]:dp[i+1][2]+c[i]);
      |                   ~~~^~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
/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:   template argument deduction/substitution failed:
a.cc:20:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |     else dp[i][1]=max(dp[i+1][0]+a[i]:dp[i+1][2]+c[i]);
      |                   ~~~^~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
a.cc:23:38: error: expected ')' before ':' token
   23 |     else dp[i][2]=max(dp[i+1][1]+b[i]:dp[i+1][0]+a[i]);
      |                      ~               ^
      |                                      )
a.cc:23:22: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   23 |     else dp[i][2]=max(dp[i+1][1]+b[i]:dp[i+1][0]+a[i]);
      |                   ~~~^~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
/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:   template argument deduction/substitution failed:
a.cc:23:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   23 |     else dp[i][2]=max(dp[i+1][1]+b[i]:dp[i+1][0]+a[i]);
      |                   ~~~^~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided