#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <vector>

using namespace std;

int tempo_massimo(int N, int a[], int b[])
{
    vector<int> stati = {0, 0, 0}, newStati = {0, 0, 0};
    // stato 0 prendo a , stato 1 prendo b , stato 2 skippo
    for(int i=0; i<N; i++){
        newStati[0] = max(stati[0], max(stati[1], stati[2])) + a[i];
        newStati[1] = stati[2] + b[i];
        newStati[2] = max(stati[0], stati[1]);

        stati[0] = newStati[0];
        stati[1] = newStati[1];
        stati[2] = newStati[2];
    }

    return max(stati[0], max(stati[1], stati[2]));
}
