cswork / OA打开练习工作台

SnowflakeOA #26

Efficient Deployments

估计困难可在线判题

考点(AI 标注)状态机

Processors are arranged in a chain and deployed one at a time. When processor i is deployed, if 0, 1, or 2 of its neighbors are already deployed, it earns no[i], one[i], or both[i], respectively. The first and last processors have only one neighbor. Maximize the total profit of all processors.

输入格式

The first line contains n, followed by 3 lines: no, one, and both. 1≤n≤100000, and each profit is in 1..10⁹. Original example 1 wrote both as 0, which conflicts with the constraints; this site's examples use valid positive profits, and the algorithm does not rely on positivity.

输出格式

Output the single integer required by the problem.

样例 1

输入:

3
2 1 3
4 2 1
1 2 3

输出:

9

样例 2

输入:

2
1 6
2 3
3 2

输出:

8

样例 3

输入:

1
7
100
1000

输出:

7

样例说明

The answers to the three public examples are, in order: 9; 8; 7. The examples were rechecked by independent enumeration, state search, or direct simulation.