/* -*- coding: utf-8 -*- * * 2889.cc: No.2889 Rusk - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int M = 6; enum { NY, SG1, DBL, SG0, SG2, FIN }; /* typedef */ using ll = long long; /* global variables */ int as[MAX_N], bs[MAX_N], cs[MAX_N]; ll dp[MAX_N + 1][M]; /* subroutines */ inline void setmax(ll &a, ll b) { if (a < b) a = b; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); for (int i = 0; i < n; i++) scanf("%d", bs + i); for (int i = 0; i < n; i++) scanf("%d", cs + i); for (int i = 0; i <= n; i++) fill(dp[i], dp[i] + M, -1); dp[0][NY] = 0; for (int i = 0; i < n; i++) { if (dp[i][NY] >= 0) { setmax(dp[i + 1][NY], dp[i][NY] + as[i]); setmax(dp[i + 1][SG1], dp[i][NY] + bs[i]); setmax(dp[i + 1][DBL], dp[i][NY] + cs[i]); } if (dp[i][SG1] >= 0) { setmax(dp[i + 1][SG1], dp[i][SG1] + bs[i]); setmax(dp[i + 1][DBL], dp[i][SG1] + cs[i]); setmax(dp[i + 1][SG0], dp[i][SG1] + as[i]); } if (dp[i][DBL] >= 0) { setmax(dp[i + 1][DBL], dp[i][DBL] + cs[i]); setmax(dp[i + 1][SG2], dp[i][DBL] + bs[i]); setmax(dp[i + 1][FIN], dp[i][DBL] + as[i]); } if (dp[i][SG0] >= 0) { setmax(dp[i + 1][SG0], dp[i][SG0] + as[i]); setmax(dp[i + 1][SG2], dp[i][SG0] + bs[i]); } if (dp[i][SG2] >= 0) { setmax(dp[i + 1][SG2], dp[i][SG2] + bs[i]); setmax(dp[i + 1][FIN], dp[i][SG2] + as[i]); } if (dp[i][FIN] >= 0) { setmax(dp[i + 1][FIN], dp[i][FIN] + as[i]); } } ll maxd = *max_element(dp[n], dp[n] + M); printf("%lld\n", maxd); return 0; }