Language: C++

#include<bits/stdc++.h>
using namespace std;
 
// #define DEBUG
#define fi first
#define se second
#define be begin
#define en end
#define pb push_back 
#define mp make_pair 
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>())   //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                  //sort in ascending order for array
#define SORTVD(a) sort(ALL(a),greater<int>())        //sort in descending order for vector type
#define SORTVA(a) sort(ALL(a))                //sort in ascending order for vector type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef vector<int> Vi;
typedef vector< Vi > VVi;
typedef vector< Pii > VPii;
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;
 
const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};
 
const double PI=3.141592653589793;
 
//scan
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(Pii *a){scanf("%d",&a->fi);scanf("%d",&a->se);}       //scan for type pair<int, int>
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
//print 
void PRINT(int a){printf("%d\n",a);}
void PRINT(int *a,int s,char c='\n'){int i;REP(i,s){if(i==s-1){c='\n';}printf("%d%c",a[i],c);}}
void PRINT(LL a){printf("%lld\n",a);}
void PRINT(LL *a,int s,char c='\n'){int i;REP(i,s){if(i==s-1){c='\n';}printf("%lld%c",a[i],c);}}
void PRINT(double a){printf("%.15f\n",a);}
void PRINT(double *a,int s,char c='\n'){int i;REP(i,s){if(i==s-1){c='\n';}printf("%f%c",a[i],c);}}
void PRINT(char a){printf("%c\n",a);}
void PRINT(string a){printf("%s\n",a.c_str());}
 
//sort and remove duplicates for type vector
void UNIQUE(Vi &a){
	SORTVD(a);
	a.erase(unique(a.be(),a.en()),a.en());
}
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
long double pascalTri(int n,int r){
	long double tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]+tri[i-1][j]);}
		}
	}
	return tri[n][r];
}
 
LL GCD(LL a,LL b){
	LL t;
	if(a<b){t=a;a=b;b=t;}
	if(b==0){return a;}
	LL r;
	while(a%b!=0){r=a%b;a=b;b=r;}
	return b;
}
 
LL LCM(LL a,LL b){LL ab=(a*b)%MOD;return ab/GCD(a%b,b);}
 
double area(Pii a,Pii b,Pii c){
	return ((b.fi-a.fi)*(c.se-a.se)-(b.se-a.se)*(c.fi-a.fi))/2.;
}
 
int checkCross(Pii v1,Pii v2,Pii a,Pii b){
	// cout<<area(v1)<<" "<<area(v2)<<endl;
	if(area(a,b,v1)*area(a,b,v2)>=0){return 0;}
	if(area(v1,v2,a)*area(v1,v2,b)>=0){return 0;}
	return 1;
}
 
const int csize=1;
int dist[csize][csize];
void floyd(int n){
	int i,j,k;
	REP(k,n){REP(i,n){REP(j,n){dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);}}}
}
 
//Bipartite method : x^n
LL BMPow(int x,int n,int m=0){
	LL ans=1;LL p=x;
	if(m==0){
		while(n>0){if(n&1==1){ans*=p;} p*=p; n>>=1;}
	}
	else{
		while(n>0){if(n&1==1){ans=(ans*p)%m;} p=(p*p)%m ;n>>=1;}
	}
	return ans;
}
 
//x^-1=x^(m-2) mod m
LL modInv(LL x,int m){return BMPow(x,m-2,m);}
 
//x! or x! mod m
LL factorial(int x,int m=0){
	int i; LL a=1;
	if(m==0){REPD2(i,x,1){a*=i;}}else{REPD2(i,x,1){a=(a*i)%m;}}
	return a;
}
 
//centroid of polygon
Pdd centroidPolygon(Pii *a,int n){
	Pdd G; G.fi=0.; G.se=0.;
	REP(i,n){ G.fi+=a[i].fi; G.se+=a[i].se; }
	G.fi/=n;G.se/=n;
	return G;
}
 
// sign of val
template <typename T> 
int sgn(T val) {
    return (T(0) < val) - (val < T(0));
}


int n;
int a[2][100];
LL dfs(int y,int x,LL sum){
	if(y==1&&x==n-1){
		sum+=a[y][x];
		return sum;
	}

	int tmp=0;
	if(x<n){
		tmp=dfs(y,x+1,sum);
	}
	if(y==0){
		tmp=max(tmp,dfs(y+1,x,sum));
	}
	sum+=(a[y][x]+tmp);

	return sum;
}

int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int i,j,k;
	

	FILL(a,0);
	SCAN(&n);
	REP(i,2){
		REP(j,n){
			SCAN(&a[i][j]);
		}
	}

	#ifdef DEBUG
		auto start=chrono::system_clock::now();
	#endif

	LL ans=dfs(0,0,0);
		
	PRINT(ans);


	#ifdef DEBUG
		auto end=chrono::system_clock::now();
		cout<<"Elapsed time : "<<chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms."<<endl;
	#endif
 
	return 0;
}

Compiler output:
a.cc: In function 'LL dfs(int, int, LL)':
a.cc:163:24: error: no matching function for call to 'max(int&, LL)'
  163 |                 tmp=max(tmp,dfs(y+1,x,sum));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~
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:163:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
  163 |                 tmp=max(tmp,dfs(y+1,x,sum));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~
/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:163:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  163 |                 tmp=max(tmp,dfs(y+1,x,sum));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~