#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using ll=long long;
vector<vector<ll>> dp;
vector<int> a,b;
ll ric(int n, int t){
    if (n<0) return 0;
    if (dp[n][t]!=-1) return dp[n][t];
    if (t==0) return dp[n][t]=a[n]+max(ric(n-1,0),ric(n-1,1));
    return dp[n][t]=b[n]+max(ric(n-2,0),ric(n-2,1));
}
int tempo_massimo(int n, int A[], int B[])
{
    a.assign(n,0);b=a;
    for (int i=0;i<n;i++) {a[i]=A[i];b[i]=B[i];}
    dp.assign(n,{-1,-1});
    return max(ric(n-1,0),ric(n-1,1));
}





