1678:走走跳跳

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:11 解决:6

题目描述

有 lns="http://www.w3.org/1998/Math/MathML"> 个位置排成一排,第 lns="http://www.w3.org/1998/Math/MathML"> 个位置都有一个分数 lns="http://www.w3.org/1998/Math/MathML">(分数可能是正数,也可能是负数)。小爱从 lns="http://www.w3.org/1998/Math/MathML">1 号位置出发,最终要走到 lns="http://www.w3.org/1998/Math/MathML"> 号位置。当小爱在第 lns="http://www.w3.org/1998/Math/MathML"> 个位置时,有两种选择:

  • 她可以直接走到下一个位置(也就是 lns="http://www.w3.org/1998/Math/MathML">+1 号位置);
  • 也可以选择跳到第 lns="http://www.w3.org/1998/Math/MathML"> 号位置(保证lns="http://www.w3.org/1998/Math/MathML"><)。

小爱的得分就是一路上经过的所有位置的分数之和,请问应该如何安排行动,才能使获得的分数之和达到最大?

输入

第一行:一个整数 lns="http://www.w3.org/1998/Math/MathML">
第二行:lns="http://www.w3.org/1998/Math/MathML"> 个整数,表示 lns="http://www.w3.org/1998/Math/MathML">1,2, ,
第三行:lns="http://www.w3.org/1998/Math/MathML">1个整数,表示 lns="http://www.w3.org/1998/Math/MathML">1,2, ,1


  • 对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,保证 lns="http://www.w3.org/1998/Math/MathML">1100,000
  • lns="http://www.w3.org/1998/Math/MathML">107107
  • lns="http://www.w3.org/1998/Math/MathML"><


输出

单个整数:表示可能拿到的最高分数

样例输入-1 复制

3
4 -2 6
3 3

样例输出-1 复制

10